Class: Docent::Link

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/docent/link.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/docent/link.rb', line 9

def self.link_for(controller=nil, action=nil)
  if (links = self.where(controller: controller).
              where(self.arel_table[:action].eq(action)).
              where(self.arel_table[:action].not_eq(''))).length > 0
    links.first.url
  elsif (links = self.where(controller: controller).
                 where(self.arel_table[:action].eq(''))).length > 0
    links.first.url
  else
    Docent.default_link
  end
end

Instance Method Details

#shortcutObject



5
6
7
# File 'app/models/docent/link.rb', line 5

def shortcut
  "#{controller}##{action}"
end