-1
我有以下关系:我的编辑操作使用创建行动,而不是更新
store.rb -> has_many :products
product.rb -> belongs_to :store
的routes.rb
resources :stores do
resources :products
end
builds_controller.rb
def edit
@build = Build.find(params[:id])
@user = User.find(@build.user_id)
@hero = Hero.find(@build.hero_id)
@heros = Hero.order('name ASC')
@items = Item.order('name ASC')
unless current_user.id == @user.id
respond_to do |format|
format.html { redirect_to root_path, notice: 'You are only allowed to edit your own builds' }
end
end
end
出于某种原因,每当我尝试去构建编辑页面并尝试编辑它时,它会运行创建而不是更新。
任何人都知道这可能是什么原因?
此外,我想编辑页面上的表单填写与构建的当前数据。我如何实现这一目标?
我的回购:https://github.com/imjp/DotA-Items
感谢授权。它仍然在创建新版本而不是更新版本:/ – imjp 2011-12-26 23:31:24
当您进入版本的编辑页面时,输入内容会填充版本信息? – Robin 2011-12-26 23:47:15
它现在工作!谢啦。但是,当我进入编辑操作时,它仍然没有填充字段。有什么建议么? – imjp 2011-12-26 23:59:47