【发布时间】:2009-10-28 19:26:19
【问题描述】:
如果我有一个包含多种形式的现有记录的页面:
index.html.haml
- for selection in @selections
- form_for selection, :method => :put do |form|
= form.collection_select :user_id, @current_account.users, :id, :full_name
然后这是提交和更新操作:
selections_controller.rb
def update
selection = Selection.find(params[:id])
if selection.update_attributes(params[:selection])
flash[:notice] = "Save!"
redirect_to selections_path
else
flash[:errors] = "Errors"
render :index
end
end
如果我在同一页面上有多个表单,我该如何处理错误消息。 即如果我想使用:
selection.errors.on(:user_id)
其中一种形式?
【问题讨论】:
标签: ruby-on-rails forms