开发者

rails 3 form throws undefined method `model_name'

userhome_controller:

  def edit_reviewer_email
    @user = User.find(params[:id])
  end

edit_reviewer_email:

<div class="pagetop center">
    <%= form_for @user, update_reviewer_email_userhome_path(@user) do |f| %>
        <%= f.label :email %><br />
        <开发者_Go百科;%= f.text_field :email, :size => 1 %>
        <%= f.submit %>
    <% end %>
</div>

error:

undefined method `stringify_keys' for "/userhome/18/update_reviewer_email":String

Should i be using form_tag when the model is accessed via a different controller?

I am looking for a rails 3 tutorial that covers a variety of forms if you know of any. Thanks!


Your controller needs to limit its request to a single record (you can just use find):

@user = User.find(params[:id])

Or if you want to stick with a where statement:

@user = User.where("id = ?", params[:id]).first
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜