Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialScott Lundgren
Courses Plus Student 12,521 PointsSign In Form NoMethodError in Devise/sessions#new
I'm using ruby 1.9.3p448, rails 3.2.16, devise 3.2.4, simple_form 2.1.1. The error
undefined method `input' for #<ActionView::Helpers::FormBuilder:0x007fd3a3b907e8>
occurs at http://localhost:3000/users/sign_up
My app/views/devise/sessions/new.html.erb looks like:
<%= form_for(resource, as: resource_name, url: session_path(resource_name), html: {class: "well"}) do |f| %>
<%= f.input :email %>
<%= f.input :password %>
<% if devise_mapping.rememberable? -%>
<div><%= f.input :remember_me, as: :boolean %></div>
<% end -%>
<div><%= f.submit "Sign in" %></div>
<% end %>
<%= render "devise/shared/links" %>
My app/views/layouts/application.html.erb includes
<li><%= link_to "Log In", new_user_session_path %></li>
and running rake routes produces
new_user_session GET /users/sign_in(.:format) devise/sessions#new
I've stopped & restarted rails s and I still get the error. I've run "rake db:reset" and "rake db:migrate" dropping all my statuses and users and I still get the error.
I understand that when devise calls the sign in view that the view s not finding simple_form to call the input method on. But how to correct the problem is where I'm stuck.
2 Answers
Calvin Nix
43,828 PointsI believe that your error is on the first line.
<%= form_for(resource, as: resource_name, url: session_path(resource_name), html: {class: "well"}) do |f| %>
I believe that you need to specify that it is a simple form. So you would do this instead...
<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name), html: {class: "well"}) do |f| %>
Scott Lundgren
Courses Plus Student 12,521 PointsDoh! That was it. I overlooked it. Thank you!