Module: Wallaby::Urlable
- Included in:
- ApplicationConcern, ApplicationHelper
- Defined in:
- lib/concerns/wallaby/urlable.rb
Overview
All URL helpers for Engine
Instance Method Summary collapse
-
#edit_path(resource, url_params: {}) ⇒ String
Generate the resourceful edit path for given resource.
-
#index_path(model_class, url_params: {}) ⇒ String
Generate the resourceful index path for given model class.
-
#new_path(model_class, url_params: {}) ⇒ String
Generate the resourceful new path for given model class.
-
#show_path(resource, url_params: {}) ⇒ String
Generate the resourceful show path for given resource.
-
#url_for(params = nil, options = {}) ⇒ String
Override original method to handle URL generation **when Wallaby is mounted as Rails Engine**.
Instance Method Details
#edit_path(resource, url_params: {}) ⇒ String
Generate the resourceful edit path for given resource.
60 61 62 63 64 65 66 67 |
# File 'lib/concerns/wallaby/urlable.rb', line 60 def edit_path(resource, url_params: {}) decorated = decorate resource with_query = url_params.delete :with_query url_for( { action: :edit, id: decorated.primary_key_value }.merge(url_params), { model_class: decorated.model_class, with_query: with_query } ) end |
#index_path(model_class, url_params: {}) ⇒ String
Generate the resourceful index path for given model class.
23 24 25 26 27 28 29 |
# File 'lib/concerns/wallaby/urlable.rb', line 23 def index_path(model_class, url_params: {}) with_query = url_params.delete :with_query url_for( { action: :index }.merge(url_params), { model_class: model_class, with_query: with_query } ) end |
#new_path(model_class, url_params: {}) ⇒ String
Generate the resourceful new path for given model class.
35 36 37 38 39 40 41 |
# File 'lib/concerns/wallaby/urlable.rb', line 35 def new_path(model_class, url_params: {}) with_query = url_params.delete :with_query url_for( { action: :new }.merge(url_params), { model_class: model_class, with_query: with_query } ) end |
#show_path(resource, url_params: {}) ⇒ String
Generate the resourceful show path for given resource.
47 48 49 50 51 52 53 54 |
# File 'lib/concerns/wallaby/urlable.rb', line 47 def show_path(resource, url_params: {}) decorated = decorate resource with_query = url_params.delete :with_query url_for( ParamsUtils.presence(action: :show, id: decorated.try(:primary_key_value)).merge(url_params), { model_class: decorated.model_class, with_query: with_query } ) end |
#url_for(params = nil, options = {}) ⇒ String
Override original method to handle URL generation **when Wallaby is mounted as Rails Engine**.
13 14 15 16 17 |
# File 'lib/concerns/wallaby/urlable.rb', line 13 def url_for(params = nil, = {}) (![:super] && EngineUrlFor.execute(context: self, params: params, options: )) || super(params) end |