Module: ActsAsRailable::Routable

Extended by:
ActiveSupport::Concern
Defined in:
lib/acts_as_railable/routable.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.polymorphic_path(record_or_hash_or_array, options = {}) ⇒ Object



8
9
10
# File 'lib/acts_as_railable/routable.rb', line 8

def self.polymorphic_path(record_or_hash_or_array, options = {})
  Rails.application.routes.url_helpers.polymorphic_path(record_or_hash_or_array, options)
end

.polymorphic_url(record_or_hash_or_array, options = {}) ⇒ Object



12
13
14
# File 'lib/acts_as_railable/routable.rb', line 12

def self.polymorphic_url(record_or_hash_or_array, options = {})
  Rails.application.routes.url_helpers.polymorphic_url(record_or_hash_or_array, options)
end

.record_action_path(record_or_hash_or_array, record_self, action, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/acts_as_railable/routable.rb', line 16

def self.record_action_path record_or_hash_or_array, record_self, action, options={}
  record_or_hash_or_array = Array(record_or_hash_or_array)
  record_or_hash_or_array << record_self if record_or_hash_or_array.exclude?(record_self)
  if action.present? && %w(index show).exclude?(action.to_s)
    options.merge!({action: action})
  end
  self.polymorphic_path record_or_hash_or_array, options
end

.record_action_url(record_or_hash_or_array, record_self, action, options = {}) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/acts_as_railable/routable.rb', line 25

def self.record_action_url record_or_hash_or_array, record_self, action, options={}
  record_or_hash_or_array = Array(record_or_hash_or_array)
  record_or_hash_or_array << record_self if record_or_hash_or_array.exclude?(record_self)
  if action.present? && %w(index show).exclude?(action.to_s)
    options.merge!({action: action})
  end
  self.polymorphic_url record_or_hash_or_array, options
end

Instance Method Details

#action_path(action = nil, record_or_hash_or_array = [], options = {}) ⇒ Object

instance methods



54
55
56
# File 'lib/acts_as_railable/routable.rb', line 54

def action_path action=nil, record_or_hash_or_array=[], options={}
  ActsAsRailable::Routable.record_action_path record_or_hash_or_array, self, action, options
end

#action_url(action = nil, record_or_hash_or_array = [], options = {}) ⇒ Object



58
59
60
# File 'lib/acts_as_railable/routable.rb', line 58

def action_url action=nil, record_or_hash_or_array=[], options={}
  ActsAsRailable::Routable.record_action_url record_or_hash_or_array, self, action, options
end