Module: TranslationsControllerHelpers
- Defined in:
- lib/translations_controller_helpers.rb
Class Method Summary collapse
Instance Method Summary collapse
- #target_action(options = {}) ⇒ Object
- #target_controller(options = {}) ⇒ Object
- #target_id(options = {}) ⇒ Object
- #target_locale(options = {}) ⇒ Object
- #url_for_translated(options = { }) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
3 4 5 |
# File 'lib/translations_controller_helpers.rb', line 3 def self.included(klass) klass.send :helper_method, :url_for_translated, :target_action, :target_locale end |
Instance Method Details
#target_action(options = {}) ⇒ Object
17 18 19 |
# File 'lib/translations_controller_helpers.rb', line 17 def target_action( = {}) .delete(:action) || 'show' end |
#target_controller(options = {}) ⇒ Object
12 13 14 15 |
# File 'lib/translations_controller_helpers.rb', line 12 def target_controller( = {}) translatable_params_name = .delete(:translatable_params_name) || @translatable_params_name .delete(:controller) || translatable_params_name.pluralize || params[:controller] end |
#target_id(options = {}) ⇒ Object
21 22 23 24 |
# File 'lib/translations_controller_helpers.rb', line 21 def target_id( = {}) translated = .delete(:translated) || @translated || .delete(:translatable) || @translatable .delete(:id) || translated end |
#target_locale(options = {}) ⇒ Object
7 8 9 10 |
# File 'lib/translations_controller_helpers.rb', line 7 def target_locale( = {}) translation = .delete(:translation) || @translation .delete(:locale) || (translation.locale if translation) || I18n.locale end |
#url_for_translated(options = { }) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/translations_controller_helpers.rb', line 26 def url_for_translated( = { }) defaults = { :locale => target_locale(), :controller => target_controller(), :action => target_action(), :id => target_id() } url_for(defaults.merge()) end |