Accessing objects in semantic_fieds_for loop / formtastic
Model has accepts_nested_attributes_for for the relation and the form is as follows:
= semantic_form_for @obj, :url => path do |f|开发者_运维百科
= f.inputs do
= f.input :name
= f.semantic_fields_for :photos do |p|
= p.inputs :desc
= f.buttons
The form works well and everything is fine. However, I would like to display each photo near the field, so the user could se which picture she is going to annotate. Is there anyway, to access photo.id inside the fields_for loop?
Edit:
Is there any way to alter the order in which photos fields will be rendered in this example. As far as I can tell till now, that order is pretty random.
Well this was easy enough, the object is accesible by:
p.object
:-)
Second part of the question is solved with:
default_scope order(...)
精彩评论