Monday, January 05, 2009

The --include-activation and --aasm parameters of the Restful Authentication Rails Plugin are mutually exclusive

I was following the installation instructions for the Restful Authentication Rails plugin. So I executed:

script/generate authenticated user sessions --include-activation -—aasm --rspec

This resulted in:

premature end of regular expression: /\A

After digging into the source code, I found that the parse! method in /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/rails_generator/options.rb swallowed exceptions. Here is the original code.

def parse!(args, runtime_options = {})
  self.options = {}
  @option_parser = OptionParser.new do |opt|
    opt.banner = banner
    add_options!(opt)
    add_general_options!(opt)
    opt.parse!(args)
  end

  return args

  ensure
    self.options = full_options(runtime_options)
end

The OptionParser initialization may cause exceptions which are not properly handled. I don't know what should be down but added the following code immediately before the ensure line at least will show the exception.

    rescue => e
    puts("I caught a #{e.class.to_s} with message #{e.to_s}")

Now that the exception is displayed, I saw one of my underlying problems:

I caught a OptionParser::InvalidOption with message invalid option: --include-activation

So I learned that when the --aasm parameter is used, then the --include-activation must not be specified.

Post a Comment