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

  • SEARCH
  • Home
  • 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 8874687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:47:06+00:00 2026-06-14T18:47:06+00:00

I have an event model and a venue model. Each event has 1 venue.

  • 0

I have an event model and a venue model. Each event has 1 venue. But a venue can have multiple events. As part of the event creation process I also want to capture info about the venue and store it. Right now I’m struggling with the nested form setup. I get the following error:

ActiveRecord::UnknownAttributeError in EventsController#new
unknown attribute: event_id

Event Model

class Event < ActiveRecord::Base
attr_accessible :name, :budget, :user_id, :venue_id, :client, :date, :description, 
:attendees, :assets_attributes, :tag_list, :venue_attributes
belongs_to :user

has_many :assets, :dependent => :destroy
has_many :vendors
has_one :venue

accepts_nested_attributes_for :assets, :allow_destroy => true
accepts_nested_attributes_for :vendors, :allow_destroy => true
accepts_nested_attributes_for :venue, :allow_destroy => true
acts_as_taggable
end

Venue Model

class Venue < ActiveRecord::Base
attr_accessible :capacity, :city, :contact, :country, :email, :exclusiveVendors,:fee, 
:latitude, :longitude, :name, :state, :street, :tel, :union
belongs_to :event
has_many :vendors
acts_as_gmappable
has_many :events
end

Event Controller

def new
  @event = Event.new
  5.times { @event.assets.build }
  venue = @event.build_venue()
  # respond_to do |format|
  #   format.html # new.html.erb
  #   format.xml  { render :xml => @event }
  # end

end

def create
  @user = current_user
  @event = Event.new(params[:event])
  @event.create_venue()

  5.times { @event.build_assets}
  if @event.save
    redirect_to @event, :notice => "Successfully created event."
  else
    render :action => 'new'
  end
end

Form (excerpt)

<%= f.fields_for :venue do |builder| %>

    <%= builder.label :name %><br />
    <%= builder.text_field :name %>

<% end %>
  • 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-06-14T18:47:07+00:00Added an answer on June 14, 2026 at 6:47 pm

    I think you got the relationship wrong here. The Venue Model should have has_many :events and Event model should have belongs_to :venue and a field named venue_id.

    And get rid of has_one :venue from Event model and belongs_to :event from Venue model.

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

Sidebar

Related Questions

I have two model objects: Event Venue Events have Venues. Venues can have 1..*
I have a model Events and each event contains an array of ids for
I have an event model which has start_at of type datetime. How can I
I have an event, a vendor, and a venue model. An event can have
I would like to have one model (event) that has multiple polymorphic HABTM associations
Does jquery/javascript have any event model that you can attach to your objects? Basically
I have a model called Event and another called Product. An event has many
Suppose I have an model object Event that contains a Venue . When I
I have a event model that has many invitations. Invitations are setup through checkboxes
So, I have an Event model that has a starts_at and a ends_at column

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.