Class: Menu
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Menu
- Defined in:
- app/models/menu.rb
Overview
Schema Information
Table name: menus
id :integer not null, primary key
title :string(255)
target :string(255)
css_class :string(255)
active :boolean default(TRUE)
created_at :datetime not null
updated_at :datetime not null
ancestry :string(255)
sorter :integer default(0)
description :text
call_to_action_name :string(255)
description_title :string(255)
image_id :integer
Instance Method Summary collapse
Instance Method Details
#has_active_child?(request) ⇒ Boolean
49 50 51 52 |
# File 'app/models/menu.rb', line 49 def has_active_child?(request) @has_active_child_result ||= {} @has_active_child_result[request.path.squeeze("/").split("?")[0]] ||= self.descendants.map(&:target).include?(request.path.squeeze("/").split("?")[0]) end |
#is_active?(request) ⇒ Boolean
44 45 46 47 |
# File 'app/models/menu.rb', line 44 def is_active?(request) @is_active_result ||= {} @is_active_result[request.path.squeeze("/").split("?")[0]] ||= request.path.squeeze("/").split("?")[0] == self.target.gsub("\"",'') end |
#mapped_to_article? ⇒ Boolean
54 55 56 |
# File 'app/models/menu.rb', line 54 def mapped_to_article? @mapped_to_article_result ||= Article.select([:url_name, :startpage, :ancestry, :id]).map{|a| a.public_url}.uniq.include?(self.target) end |