我试图链接以创建动作,并想像
<%= link_to "Create new user", {controller: 'users' , action: 'create'}, method: 'post' %>
,但是当我单击生成的链接时,什么也没有发生,并且 url 更改为
http://0.0.0.0:3000/users?method=POST+%2Fusers
这表明该请求是作为 GET 请求而不是 POST 处理的,有什么想法吗?
这是用户控制器的创建操作
def create
@user = User.new params[:user]
if @user.save
flash[:notice] = 'User has successfully been created.'
redirect_to users_path
else
flash[:notice] = 'There was an error creating this user.'
redirect_to :back
end
end