Bob Sanders
2008-Mar-31 07:55 UTC
Requiring User to Select Categories -- (on Post Creation)
Hello, I''m having trouble with validation. I want to require the user to select a category before a post is successfully created. I''m using has_many :through for posts and categories as follows: class Post < ActiveRecord::Base has_many :categorizations has_many :categories, :through => :categorizations end class Categorization < ActiveRecord::Base belongs_to :category belongs_to :post end class Category < ActiveRecord::Base has_many :categorizations has_many :posts, :through => :categorizations end I''ve tried validates_presence_of :categorizations in the Post model, but the application simply saves it without verifying that the user selected a checkbox. Any ideas what I can do? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---