大家好,我是 ror 的新手,最近在做一个 project,目的是创造一个打印界面,在一个 printout 上打出好几个 printout fields 我有两个 model,一个 printout.rb,
has_many :printout_fields
另一个是 printout_field.rb,
belongs_to :printout
数据库如下:
printout:
我要做的就是有个网页,
但是接下来是要在每个 printout 里面加入一个一个 field,首先是按 new fields,进入这个页面,
在我的 manage_printout_field controller 里面,在 edit action 中,我用@printoutfield = PrintoutField.find(params[:id]) 并不能找到 @printoutfield,错误显示为
Couldn't find PrintoutField without an ID
只有打@printoutfield = PrintoutField.find(1),才能取到 printout_field_id 是 1 的这个 field,而当右击准备修改的时候,每个 field 所对应的默认值都是 id 是 1 的这个 field 的值,这个我知道是因为我 hard code 了 id 是 1,但是我想知道我如何在 edit?printout_id=1 的这个页面上来对每个 field 可以进行操作。
我觉得我的 controller 并没有办法获得这个 parameter,我也试了很多不同的名字,都行不通,有什么办法可以动态的来操作这个界面? 谢谢!!