0

Im getting the following error when attempting to build a list of 'interests' check boxes in my form (models also listed below)... Any ideas? Thanks!

ActiveRecord::StatementInvalid in User_steps#show

Showing /Users/nelsonkeating/Desktop/ReminDeal/app/views/user_steps/show.html.erb where line #19 raised:

SQLite3::SQLException: no such column: person_interests.interest_id: SELECT "interests".* FROM "interests" INNER JOIN "person_interests" ON "interests"."id" = "person_interests"."interest_id" WHERE "person_interests"."person_id" = 11 AND "person_interests"."person_type" = 'User'
Extracted source (around line #19):

16:   <legend>Interests & Holidays</legend>
17:   <h4>Select your top 3 interests..</h4>
18: 
19: <%= f.simple_fields_for :interests do |interest_f| %>
20:   <%= interest_f.input :interest, :as => :check_boxes, :label => false %>
21:    <% end %>
22:   <br></br>



class User < ActiveRecord::Base

  attr_accessible :name, :email, :password, :password_confirmation, :remember_me,     :interests_attributes, :city, :zipcode, :date_of_birth, :gender, :address, :interest_ids, :holiday_ids, :friends_attributes, :person_interest_ids, :friends
  has_many :friends
  has_many :person_interests, :as => :person
  has_many :interests, :through => :person_interests

  accepts_nested_attributes_for :friends,  allow_destroy: true
  accepts_nested_attributes_for :interests, allow_destroy: true

end

class PersonInterest < ActiveRecord::Base
  attr_accessible :person_id, :person_type
  belongs_to :interest
  belongs_to :person, :polymorphic => true
end


class Interest < ActiveRecord::Base
  attr_accessible :name
  has_many :person_interests
  has_many :people, :through => :person_interests
end
3
  • I may not know a darn thing about rails, but based on the error you're getting, it sounds to me like your person_interests table doesn't have a column named interest_id. Commented May 18, 2012 at 18:03
  • Are you up to date on your migrations? Commented May 18, 2012 at 18:19
  • yes, @Travesty3 was right, i needed an interest_id column.. the forms are now appearing but not saving to the database Commented May 18, 2012 at 18:50

1 Answer 1

2

Based on this error message:

SQLite3::SQLException: no such column: person_interests.interest_id

It appears that your person_interests table does not have a column named interest_id.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.