Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/ask/acts_as_answerer.rb,
lib/ask/acts_as_asker.rb more...
Class Method Summary collapse
Class Method Details
permalink .acts_as_answerer ⇒ Object
[View source]
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/ask/acts_as_answerer.rb', line 101 def self.acts_as_answerer include Ask::ActiveRecord::InstanceMethods has_many :answers, :as => :answerer, :dependent=>:destroy has_many :questions, :through=>:answers if respond_to? :attr_accessible # Rails 3.2 backwards compatibility attr_accessible :answers_attributes end accepts_nested_attributes_for :answers, :allow_destroy=>true validate :validate_required_questions end |
permalink .acts_as_asker ⇒ Object
[View source]
2 3 4 5 6 7 8 9 |
# File 'lib/ask/acts_as_asker.rb', line 2 def self.acts_as_asker has_many :questions, :as => :asker, :dependent => :destroy if respond_to? :attr_accessible # Rails 3.2 backwards compatibility attr_accessible :questions_attributes end accepts_nested_attributes_for :questions, :allow_destroy=>true, :reject_if=>lambda{|attrs| attrs['name'].blank? } end |