Flowdock
method

add_options!

Importance_1
Ruby on Rails latest stable (v6.1.7.7) - 1 note - Class: Rails::Generator::Options

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v2.3.8) is shown here.

add_options!(opt) protected

Override to add your options to the parser:

  def add_options!(opt)
    opt.on('-v', '--verbose') { |value| options[:verbose] = value }
  end
Show source
Register or log in to add new notes.
July 14, 2010
0 thanks

If you need to pass a value

In the above example ‘value’ happens to be either true or false depending if the option was passed in or not. If you wish to capture an actual value you’ll want something like this:

def add_options!(opt)
  opt.on('-option=value') { |value| options[:option] = value }
end