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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:10:50+00:00 2026-06-15T21:10:50+00:00

I’m pretty sure I have my models set up correctly for a standard has_many

  • 0

I’m pretty sure I have my models set up correctly for a standard has_many :through relationship…however, I used a rails generator for a model to create it and the first time i ran it, i accidentally created a model called Categorizations (plural) instead of Categorization and went all the way through setting everything up before i realized the error. I rolled back the migration and deleted the 4 files created by the generator (migration, model, spec, factory). I started over again and i’m still getting
Association :category not found as the error.

my main question:
Is there anything else I need to undo because I accidentally created and deleted a model with a plural name?

Followup question:
If that’s not the issue, then what am I doing wrong? Is there some glaring oversight because i’ve been staring at this so long?

Follow up to the follow up:
What else can I do to help troubleshoot this issue? All of the models are accessible in the console and seem to be set up correctly. is there a rake routes for model associations?

Here is what i have in my view:

<%= f.association :category %>

I’ve also tried:

<%= f.association :category, :required => true, :collection => @categories, :as => :check_boxes, :label => "Categories:" %> (I have @categories set in the controller

Here are the models:

class PressRelease < ActiveRecord::Base
  has_many :categorizations
  has_many :categories, :through => :categorizations

  belongs_to :user
  belongs_to :press_contact

  attr_accessible :body, :summary, :user_id, :headline, :link, :press_contact_id, :publish_date, :subheadline

  self.per_page = 5

  def published
    "#{self.publish_date.strftime("%A, %B %d, %Y")}"
  end

end

class Category < ActiveRecord::Base
  has_many :categorizations
  has_many :press_releases, :through => :categorizations
  attr_accessible :description, :label
end

class Categorization < ActiveRecord::Base
  belongs_to :category
  belongs_to :press_release

  attr_accessible :category_id, :press_release_id

end

update: This all works in the console:

pr = PressRelease.first
pr.categories
Category Load (0.2ms)  SELECT "categories".* FROM "categories" INNER JOIN "categorizations" ON "categories"."id" = "categorizations"."category_id" WHERE "categorizations"."press_release_id" = 1

c = Category.first
c.press_releases
PressRelease Load (0.3ms)  SELECT "press_releases".* FROM "press_releases" INNER JOIN "categorizations" ON "press_releases"."id" = "categorizations"."press_release_id" WHERE "categorizations"."category_id" = 21
 => [] 

So the association seems to be working on some level. i’m getting more and more confident that i’m missing something little and obvious or giant and glaring. please help! thanks!

  • 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-15T21:10:52+00:00Added an answer on June 15, 2026 at 9:10 pm

    If you are working over PressRelease you should use <%= f.association :categories %>, change the :category for :categories, because of the relation.

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

Sidebar

Related Questions

I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.