This project is archived and is in readonly mode.

#4397 ✓stale
DT

Generators depend on ActiveRecord

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

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.

Comments and changes to this ticket

  • Ryan Bigg

    Ryan Bigg April 27th, 2010 @ 08:48 AM

    • 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)
    
  • Ganesh Shankar

    Ganesh Shankar April 27th, 2010 @ 10:51 AM

    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
    
  • Ganesh Shankar

    Ganesh Shankar April 27th, 2010 @ 10:53 AM

    @DT

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

  • Mike Riley

    Mike Riley July 29th, 2010 @ 08:45 PM

    • 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

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:34 PM

    • 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.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:34 PM

    • State changed from “open” to “stale”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages