Module: PagesCore::PageModel::Redirectable

Extended by:
ActiveSupport::Concern
Included in:
Page
Defined in:
app/models/concerns/pages_core/page_model/redirectable.rb

Instance Method Summary collapse

Instance Method Details

#redirect_path(params = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/concerns/pages_core/page_model/redirectable.rb', line 21

def redirect_path(params = {})
  path = redirect_to.dup
  if path.start_with? "/"
    params.each do |key, value|
      unless value.is_a?(String) || value.is_a?(Symbol)
        raise InvalidRedirectUrl, "must be a string or a symbol"
      end

      path.gsub!("/:#{key}", "/#{value}")
    end
  end
  path
end

#redirects?Boolean

Returns boolean true if page has a valid redirect

Returns:

  • (Boolean)


17
18
19
# File 'app/models/concerns/pages_core/page_model/redirectable.rb', line 17

def redirects?
  redirect_to?
end