Note that there are some explanatory texts on larger screens.

plurals
  1. PORails 3 - Multiple model forms within another model
    primarykey
    data
    text
    <p>I'm building an application in which i need to add rows to tables from multiple other models.</p> <p>This is what i have so far (sorry for the sloppy code, first project with ruby/rails). I do realize that I am still missing some key elements to the code for this to function properly, I would just like to make sure I am going about this the right way first. I will also be moving the form to a partial once i get everything working correctly.</p> <pre><code># app/views/ticketbuilder/show.html.erb &lt;ul&gt; &lt;% @event.sections.each do |s| %&gt; &lt;li&gt;&lt;%= s.name %&gt;&lt;/li&gt; &lt;ul&gt; &lt;% s.locations.each do |l| %&gt; &lt;li&gt;&lt;%= l.name %&gt;&lt;/li&gt; &lt;% end %&gt; &lt;/ul&gt; &lt;% end %&gt; &lt;li&gt; &lt;%= form_for([:event, :ticketbuilder], :url =&gt; event_ticketbuilder_url) do |s| %&gt; &lt;%= s.text_field(:section) %&gt; &lt;%= submit_tag("Add Section") %&gt; &lt;%= s.hidden_field(:event_id, @event.id) %&gt; &lt;% end %&gt; &lt;/li&gt; &lt;/ul&gt; # routes.rb resources :event do resources :ticketbuilder end # ticketbuilder_controller.rb class TicketbuilderController &lt; ApplicationController def show @event = Event.find(params[:event_id]) end def new @section = Section.new respond_to do |format| format.html # new.html.erb format.xml { render :xml =&gt; @event } end end end # error message undefined method `model_name' for Symbol:Class </code></pre> <p>The problem I am having is sending the form to the ticketbuilder controller. What I'm trying to accomplish is to have a list of seating sections with child elements for locations. I would like to be able to add new sections and locations directly on the list page.</p> <p>Any suggestions would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload