I am developing a complex form that simultaneously updates several records of the same model, while updating the associated model. It looks something like this:
class Sport
has_one :photo
end
class Photo
belongs_to :sport
acts_as_fleximage
end
class Page
end
Just to get information about background information, the page model is a general model for which users can create as many (CMS) as possible. In addition, during registration they receive a small number of mandatory "system" pages. When they try to edit the system page, the form is slightly different from the general form of the page.
- "". ( "" ) ( "" ).
, , , . , , :
:id => 1
:page => {"title"=>"Our sports"}
:sport => {
"1" => {
"description" => "<p>I love playing hockey...</p>"
"photo_attributes" => {
"image_file" =>
"description" => "Me in my hockey kit"
}
},
"2" => {
}
, , / :
def update_sports_page
@page = Page.find params[:id]
@page.update_attributes params[:page]
Sport.update(params[:sport].keys, params[:sport].values)
redirect_to
end
, , , EXCEPT, , , sport_id NULL.
, .
- , ?
(ps, , , fleximage )