Skip to content

Instantly share code, notes, and snippets.

@darkside
Created March 16, 2011 19:46
Show Gist options
  • Save darkside/873170 to your computer and use it in GitHub Desktop.
Save darkside/873170 to your computer and use it in GitHub Desktop.
class GuestFormStep < ActiveRecord::Base
class GuestFormStep < ActiveRecord::Base
abstract_class = true
translates :name, :description
belongs_to :guest_form
has_many :questions, :dependent => :destroy, :order => 'position'
validates_presence_of :name
validates_presence_of :type
validates_presence_of :guest_form
accepts_nested_attributes_for :questions, :allow_destroy => true
named_scope :with_questions do
def with_questions
self.questions.visible_to_user.any?
end
end
def after_initialize
self.build_initial_questions unless self.questions.any?
end
def step_type
self.class.class_name.titleize
end
protected
def build_initial_questions
end
def build_default_options
end
def fields_visible_to_user
end
private
def attributes_protected_by_default
super - ['type']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment