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


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

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)

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

def redirects?
  redirect_to?
end