I have an application that creates microposts under categories and 
subcategories (which I call selections). The user can write in two fields, 
the category field and the selection field. My models are:


class Micropost < ActiveRecord::Base
  attr_accessible :content, :category_content, :selection_content, 
:category_id, :selection_id, :user_id

  belongs_to :user
  belongs_to :category
  belongs_to :selection

  validates :user_id, presence: true
  validates :category_content, presence: true
  validates :selection_content, presence: true


  default_scope order: 'microposts.created_at DESC'

end


class Category < ActiveRecord::Base
  attr_accessible :content, :id, :count, :c_count
  has_many :selections
  has_many :comments

  default_scope order: 'categories.count DESC'

end


class Selection < ActiveRecord::Base
  attr_accessible :content, :count, :category_id
  belongs_to :category

  default_scope order: 'selections.count DESC'

end


In my console, when I create a user u and enter "u.microposts" I get the 
desired response (a list of microposts created by u). When I create a 
category c and enter 

"c.selections" I also get the desired response (a list of selections that 
belong to c). But when I enter "s.microposts" I get the following error 
message- "undefined 

method `microposts' for #<Selection:0x57c6b40>". Similarly, when I enter 
"u.microposts" I get the error message- "undefined method `microposts' for 

#<Category:0x45c0498>".  Any ideas why this is happening?

I am developing on Windows using RubyMine. I am definitely moving to OS X 
soon, because I have to make too many hoops working around the Windows 
environment, but I don't see why this would make a difference here. 

-- 
-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
--- 
You received this message because you are subscribed to the Google Groups "SD 
Ruby" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to