Module: ActionView::Helpers

Defined in:
lib/features/features_helper.rb

Defined Under Namespace

Classes: FormBuilder

Instance Method Summary collapse

Instance Method Details

#feature_check_box(model_name, method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/features/features_helper.rb', line 3

def feature_check_box(model_name, method, options = {}, checked_value = "1", unchecked_value = "0")
   = @template.instance_variable_get("@#{model_name}")
  throw "feature_check_box only work on models with features" unless .respond_to?(:features)
  options[:checked] = .features.send("#{method}?")
  options[:id] ||= "#{model_name}_features_#{method}"
  options[:name] = "#{model_name}[features][#{method}]"
  @template.check_box(model_name, "features_#{method}", options, checked_value, unchecked_value)
end