Displaying 3 results from an estimated 3 matches for "keywords_control".
2007 Jun 18
4
polymorphic validation
Hello
I have 2 models.
link.rb
has_many :categories, :as => :categorized
validates_presence_of :name, :url, :created_at, :category
category.rb
belongs_to :categorized, :polymorphic => true
validates_presence_of :name
Everything seems to work. I select my category from a select tag. The
problem is i don''t know how to validate if category is for example empty
(nothing in a
2006 Apr 05
4
validation on before_add callback
problem: validation error is not functionning in callback
callback for many-to-many association:
# keyword.rb
:before_add => :reject_self_related
def reject_self_related(related_keyword)
if (related_keyword == self)
# this does not work:
errors.add(:name, "Relating a keyword to itself is
forbidden!")
raise "Relating a keyword to itself is
2006 Apr 07
2
errors.add_to_base
What are the limitations on using:
errors.add_to_base
to display errors in views?
I have tried for days to add errors from my object.rb and they never get
displayed.
class Keyword < ActiveRecord::Base
validates_presence_of(:name, :message => "Name is required.")
validates_uniqueness_of(:name, :message => "This name is already in
use. Please try