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 8012523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:21:22+00:00 2026-06-04T19:21:22+00:00

I have what I think is a simple structure: class GroupEvent < ActiveRecord::Base attr_accessible

  • 0

I have what I think is a simple structure:

class GroupEvent < ActiveRecord::Base
  attr_accessible :user_id, :title, :description, :identifier, :start_date, :end_date, :time_zone, :url, :capacity, :info_url, :logo_url, :logo_ssl_url, :status

  has_one :event_venue
  has_one :event_organizer
  has_one :event_ticket
  has_one :event_condition
  belongs_to :user
end

class User < ActiveRecord::Base
  attr_accessible :email, :name, :password, :password_confirmation
  has_secure_password

  has_many :group_events
  ...
end

But in the Rails console when I execute

@user = User.new
@event = @user.group_events.build

I get an error: ActiveRecord::InverseOfAssociationNotFoundError: Could not find the inverse association for group_events (:user in GroupEvent).

Update: I still can’t get the user and the GroupEvent to see each other. GroupEvent.new and EventVenue.new create new objects, and

@event = GroupEvent.new
@venue = @event.build_event_venue

creates an @event.event_venue object, as it should. (Though I’m still confused that

@event.event_venue.build

returns a NoMethodError: undefined method `build’ for nil:NilClass.)

  • 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-04T19:21:24+00:00Added an answer on June 4, 2026 at 7:21 pm

    Update: It works now.

    @event = @user.group_event.build 
    

    creates a new GroupEvent object. For anyone coming after, I apologize, I don’t know what I did. The above code all still looks the same. I wasn’t aware that I needed to restart the console each time I made a change, but restarting the console seemed to fix my problems.

    A lingering question is bothering me. Both @user.build_group_event and @user.group_event.build generate the same result (a GroupEvent object), but for my other classes, @event.build_event_venue generates an object, but @event.event_venue.build still returns a “NoMethodError: undefined method `build’ for nil:NilClass”. I just can’t figure it out. But I have working code, so I’m not going to make too big a deal about it.

    Thank you for your help.

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

Sidebar

Related Questions

I have -- what I think -- is a simple question. Here's my code:
I have what I think is a simple question but I can't get it
I think I have a pretty simple goal but cant seem to reach it.
I have what I think should be a fairly simple mapping issue, but not
Simple question, I think. I have org.springframework.scheduling.quartz.CronTriggerBean triggering one job once a day. Because
Okay, I have what I think is a simple question.. or just a case
Below is a very simple bit of code that mimics a class structure in
Simple question I have a class say person who has as a property a
I have a set of classes that have the following structure: class U {
simple thing which I need to do is, that I have a pdf document

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.