第一次使用 ROR,我试图在表单提交时从索引视图创建一个新的模型对象。我想我明白了,但我得到:
uninitialized constant UsersController
在我看来,我有:
=form_for :user, :url => { :action => "new", :controller => "user" } do |f|
= f.text_field :username, :placeholder => 'Username', :size => 30
%br
= f.text_field :email, :placeholder => 'E-mail', :size => 30
%br
= f.password_field :password, :placeholder => 'Password', :size => 30
%br
%br
= f.submit_tag 'Sign Up'
在我的控制器中,我有:
def new
user_info = :params[:user]
@user = User.create!(user_info)
flash[:notice] = "#{@user.username} has been added! Please fill out your profile page."
redirect_to user_path
end
谁能明白我为什么会得到这个?