Sha256: 44a4030443a7d9edbc60161eec3425d7e6625cde2b5c43647f6ca9b7d0054600

Contents?: true

Size: 693 Bytes

Versions: 1

Compression:

Stored size: 693 Bytes

Contents

class Spree::Menu < ActiveRecord::Base
  
  before_validation :get_static_page_path
  
  belongs_to :menu_bar
  belongs_to :page
  
  attr_accessible :page_id, :sequence,:parent_id, :link_text, :url, :visible, :menu_bar_id
  alias_attribute :position, :sequence
  
  acts_as_tree :order => "sequence"
  
  #validates_presence_of :sequence
  #validates_numericality_of :sequence
  
  validates_presence_of :link_text
  validates_presence_of :url
  validates_presence_of :menu_bar
  
  default_scope order(:sequence)
  scope :visible, where(:visible => true)
  
  private
    def get_static_page_path
      if attribute_present?("page_id")
        self.url = self.page.path
      end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_essential_menus-0.1.8 app/models/spree/menu.rb