nbudin / heroku_external_db

Makes it easy to connect to external databases from a Heroku app
MIT License
40 stars 5 forks source link

Could not find generator heroku_external_db:generator #2

Open dlupu opened 13 years ago

dlupu commented 13 years ago

Hello Nat,

I would like to use your gem for my application. I've successfully installed it using bundle but when I run the generator I get the following error:

Could not find generator heroku_external_db:generator.

Rails 3.0.7, Ruby 1.9.1, heroku_external_db 1.0.1.

Any ideas? Or could you provide a sample of the file that the generator is supposed to generate so that i can adapt it to my needs?

Thanks! Dorian

rtlong commented 13 years ago

I also see this issue. I have basically the same environment except I'm using Rails 3.0.9 on Ruby 1.9.2

rtlong commented 13 years ago

@dlupu, I was able to work around this, though, by copying the lib/generators/heroku_external_db/templates/initializer.rb file into my app's config/initializers/ as heroku_external_db.rb. The rest of the code seems to work fine, so far.

dlupu commented 13 years ago

@rtlong thanks for the workaround. I will test this asap.

nbudin commented 13 years ago

Thanks guys! I've had no end of trouble getting the generator to appear in various versions of Rails. You'd think this would be simple but every time it seems like some version of Rails or other doesn't see it.

I'm thinking the simplest thing may be to just remove the generator and the instructions to use it, and replace it with an initializer to copy/paste out of the README. What do you think?

rtlong commented 13 years ago

I think it would be best to make the default initializer's behavior the default after having loaded the gem. That is, ditch the generic initializer. If ENV['EXTERNAL_DATABASE_URL'].present? then load the setup_rails_env! method. I don't know how one would go about this, but tell rails to load that method only if it hadn't been called already. That way, one could add an initializer (manually or by copy/paste) to implement the setup_configuration! method you outlined in the default initializer.

P.S. I have been awake for too long, so if that didn't make sense, let me know...

nbudin commented 13 years ago

I really don't want to do it that way. Personally I feel like I've wasted a lot of time having to work around gems that attempted to initialize themselves on loading. This gem, in particular, has the potential to pollute ActiveRecord configurations when being initialized.

Users having to put an initializer into their Rails configuration seems like a small price to pay for playing nice with other libraries.

rtlong commented 13 years ago

That is a good point. I'll change my answer, then: "What he said." :-)