Class: ActiveRecordJsonUrlExtension::UrlHelper

Inherits:
Object
  • Object
show all
Includes:
ActionDispatch::Routing::UrlFor
Defined in:
app/models/active_record_json_url_extension.rb

Overview

The following class generates a scope that prevents the url helpers from being included directly into ActiveRecordJsonUrlExtension and therefore into ActiveRecord::Base.

class MyModel < ActiveRecord::Base
end

my_instance = MyModel.create()

You may call my_instance.url() to get the same result as for url_for(my_instance). But you should not be able to call, for example, my_instance.my_model_path( ... ).

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ UrlHelper

Returns a new instance of UrlHelper.



35
36
37
# File 'app/models/active_record_json_url_extension.rb', line 35

def initialize( obj )
  @obj = obj
end

Instance Method Details

#urlObject



43
44
45
# File 'app/models/active_record_json_url_extension.rb', line 43

def url
  url_for @obj
end

#url_optionsObject



39
40
41
# File 'app/models/active_record_json_url_extension.rb', line 39

def url_options
  Rails.application.config.action_mailer.default_url_options
end