Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Generators depend on ActiveRecord

#4397

Steps to reproduce

  1. Remove :active_record from config.frameworks in environment.rb:

    config.frameworks -= [:active_record]
    
  2. Run script/generate migration some_name
    (Note: this particular example demonstrates the problem, but doesn't make sense. I encountered this problem while trying to run a custom generator, which generates files that do not rely on ActiveRecord. e.g. script/generate custom_migration some_name.)

Expected

The migration template should be generated.

Actual

Fails with error "uninitialized constant Rails::Generator::Commands::Base::ActiveRecord."

Notes

I've tracked down the problem to next_migration_string in Rails::Generator::Commands::Base (lib/rails_generator/commands.rb:85), which checks for ActiveRecord::Base.timestamped_migrations. A potential fix is to change line 85 from:

if ActiveRecord::Base.timestamped_migrations

to

if defined? ActiveRecord::Base and ActiveRecord::Base.timestamped_migrations

or otherwise remove the dependency.

Reported by DT · April 14th, 2010 @ 10:39 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Ryan Bigg
    Ryan Bigg
    • State changed from new to needs-more-info

    Please submit a patch in the correct format. I would suggest doing it like this:

    ActiveRecord::Base.timestamped_migrations if defined?(ActiveRecord)
    

    April 27th, 2010 @ 08:48 AM

  2. Ganesh Shankar
    Ganesh Shankar

    Tried to replicate this in Rails 3 and we get this as an output:

    rails generate migration foo
    No value provided for required options '--orm'
    

    the way we're removing ActiveRecord in our environment is: (config/application.rb)

    #require 'rails/all'
    %w(
      action_controller
      action_mailer
      active_resource
      rails/test_unit
    ).each do |framework|
      begin
        require "#{framework}/railtie"
      rescue LoadError
      end
    end
    

    April 27th, 2010 @ 10:51 AM

  3. Ganesh Shankar
    Ganesh Shankar

    @DT

    If you can provide the code for your custom generator then we can test it specifically Rails 3

    April 27th, 2010 @ 10:53 AM

  4. Mike Riley
    Mike Riley
    • Importance changed from to Low

    Hello DT,

    Just wanted to see if you could provide more info (or code) for this so we can test this against Rails 3. Let us know.

    Mike Riley

    July 29th, 2010 @ 08:45 PM

  5. Santiago Pastorino
    Santiago Pastorino
    • State changed from needs-more-info to open

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:34 PM

  6. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:34 PM