Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4104326
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:06:14+00:00 2026-05-20T21:06:14+00:00

I’m building an application in which i need to add rows to tables from

  • 0

I’m building an application in which i need to add rows to tables from multiple other models.

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.

# app/views/ticketbuilder/show.html.erb    
<ul>
<% @event.sections.each do |s| %>
  <li><%= s.name %></li>
  <ul>
    <% s.locations.each do |l| %>
      <li><%= l.name %></li>
    <% end %>
  </ul>
<% end %>
  <li>
    <%= form_for([:event, :ticketbuilder], :url => event_ticketbuilder_url) do |s| %>
      <%= s.text_field(:section) %> <%= submit_tag("Add Section") %>
      <%= s.hidden_field(:event_id, @event.id) %>
    <% end %>
  </li>
</ul>

# routes.rb
resources :event do
  resources :ticketbuilder
end

# ticketbuilder_controller.rb   
class TicketbuilderController < 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 => @event }
    end
  end
end

# error message
undefined method `model_name' for Symbol:Class

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.

Any suggestions would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T21:06:15+00:00Added an answer on May 20, 2026 at 9:06 pm

    There are a few things you need to change. First in the show action in TicketbuilderController:

      # TicketbuilderController
      def show
        @event = Event.find(params[:event_id])
        @section = Section.new
      end
    

    The @section variable is a new Section which will be used in the form_for helper in the view which comes next:

    # app/views/ticketbuilder/show.html.erb  
    <%= form_for @section, :url => event_ticketbuilder_path(@event) do |s| %>
      <p><%= s.text_field(:section) %></p>
      <p><%= s.submit("Add Section") %></p>
    <% end %>
    

    form_for takes an instance of the model you want to create, in this case a Section. The hidden field to store the event_id is not needed because we send the form data to an url which contains the event_id. That url is specified in the :url attribute passed to form_for.

    And lastly, the create action in TicketbuilderController:

    # TicketbuilderController
    def create
      @event = Event.new(params[:event_id])
      @section = @event.sections.build(params[:section)
      if @section.save
        @section = Section.new
      end
      render :action => :show
    end
    

    The @event is used to “build” the section. By doing that, the section is associated with the event even though the event_id was not passed in the form. And if the new section was succesfully saved, the @section variable is set to a new instance to prepare for the form_for again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I have thousands of HTML files to process using Groovy/Java and I need to
I have a bunch of posts stored in text files formatted in yaml/textile (from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.