Class: ActiveRecordJsonUrlExtension::UrlHelper
- Inherits:
-
Object
- Object
- ActiveRecordJsonUrlExtension::UrlHelper
- 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
-
#initialize(obj) ⇒ UrlHelper
constructor
A new instance of UrlHelper.
- #url ⇒ Object
- #url_options ⇒ Object
Constructor Details
#initialize(obj) ⇒ UrlHelper
Returns a new instance of UrlHelper.
34 35 36 |
# File 'app/models/active_record_json_url_extension.rb', line 34 def initialize(obj) @obj = obj end |
Instance Method Details
#url ⇒ Object
42 43 44 |
# File 'app/models/active_record_json_url_extension.rb', line 42 def url url_for(@obj) end |
#url_options ⇒ Object
38 39 40 |
# File 'app/models/active_record_json_url_extension.rb', line 38 def Rails.application.config.action_mailer. || raise("Please set 'config.action_mailer.default_url_options = {host: ...}' in the application config.") end |