One form to update multiple pages in Rails -


fairly new rails. i'm trying create form updates 2 models, , outputs 2 separate show pages. one, possible, , two, how? saw lot of posts 1 form being able update multiple models, not sure if can have 1 form creates 2 separate pages.

edit:

thanks comments far. and, sorry lack of clarity. have 2 models. 1 "course preview" page. , second "actual course". user can view preview page, have purchase course allowed view course page.

what trying use 1 form create "course preview" , "course" @ same time.

thanks in advance!

you can't render 2 pages @ once, user can see 1 page @ time.

but can create 1 page displays results clever coding. if have 2 models, model1 , model2, , view each one, model1/show.html.erb, can change show.html.erb code from:

<%= @model.name %> etc... 

to

<%= render 'display' %> 

create file named _display.html.erb, , put contents show.html.erb in there. now, when visit show page model1, call display partial , render information accordingly. lather, rinse, repeat model2.

so, return page dual form utilize same partial. results page form like:

<%= render 'model1/display' %>  <%= render 'model2/display' %> 

this pulls partials each model type , puts in results page.

for more information on using partials, see: http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -