My new.html.erb code in views/users:
<h1>Sign Up</h1>
<%= simple_form_for(@user) do |f| %>
<%= f.input :username %>
<%= f.input :password %>
<%= f.input :password_confirmation %>
<%= f.button :submit %>
<% end %>
this is the error:
undefined method `simple_form_for' for #<#<Class:0x9f9b568>:0xaa02440>
I know what this error is asking for:
def simple_form_for
end
but the problem is where to put it. Also this is my users_controller.rb:
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
redirect_to @user, notice: 'User was successfully created.'
else
render action: "new"
end
end
def show
@user = User.find(params[:id])
end
end
That's not what it's expecting at all.
simple_form_for means your app is expecting to have the Simple Form (https://github.com/plataformatec/simple_form) gem available, which provides that method for your forms to use. You should either install the gem, by adding it to your Gemfile, or rewrite your form to use Rails form helpers instead of Simple Form.
If it does not find the method but you had installed the gem. In that case, I think you forgot to restart the server. Restart the server and it will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With