Rails 4 form_for error: undefined method `model_name' for
ActionController::Parameters:Class
I'm trying to make a basic form for creating a user record:
<%= debug(@user) %>
<%= form_for @user, url: {action: "create_user"}, html: {class:
"user-create-form"} do |f| %>
<div class="form-group"><%= f.text_field :first_name,
class:'form-control' %></div>
<div class="form-group"><%= f.text_field :last_name,
class:'form-control' %></div>
<div class="form-group"><%= f.text_field :email, class:'form-control'
%></div>
<div class="form-group"><%= f.text_field :password,
class:'form-control' %></div>
<%= f.submit "Update" %>
<% end %>
In the controller:
def create_user
@user = params[:user]
@user = User.new if !@user
end
This loads fine and without error, but when I submit the form, I get the
following error:
NoMethodError in Admin#create_user
Showing
/Applications/MAMP/htdocs/clippo2/app/views/admin/create_user.html.erb
where line #6 raised:
undefined method `model_name' for ActionController::Parameters:Class
Extracted source (around line #6):
<%= form_for @user, url: {action: "create_user"}, html: {class:
"user-create-form"} do |f| %>
No comments:
Post a Comment