Module: ActionView::Helpers
- Defined in:
- lib/has_settings/has_settings_helper.rb
Defined Under Namespace
Classes: FormBuilder
Instance Method Summary collapse
Instance Method Details
#setting_check_box(model_name, method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/has_settings/has_settings_helper.rb', line 3 def setting_check_box(model_name, method, = {}, checked_value = "1", unchecked_value = "0") the_model = @template.instance_variable_get("@#{model_name}") throw "No @#{model_name} in scope" if the_model.nil? throw "The setting_check_box only works on models with settings" unless the_model.respond_to?(:settings) [:checked] = the_model.settings.send("#{method}?") [:id] ||= "#{model_name}_settings_#{method}" [:name] = "#{model_name}[settings][#{method}]" @template.check_box(model_name, "settings_#{method}", , checked_value, unchecked_value) end |