I don't know the name of your attribute that identifies the record as the favorite, but let's say it is a boolean
named is_favorite
. Considering this abose, the following should work:
children = Parent.find(params[:parent_id]).children
@favorited_children = children.where(is_favorite: true) # return 0..N records! not only 0..1 !
To edit its attributes, you can do as following (you will have to translate it in ERB or HAML, depending on what your app uses):
form_for @favorited_children do |form_builder|
form_builder.text_field :name
form_builder.check_box :is_favorite
end
Hope this helps!