seedbank icon indicating copy to clipboard operation
seedbank copied to clipboard

Use with Sinatra or Padrino?

Open pmackay opened this issue 9 years ago • 18 comments

I dont think seedbank is currently supported for these. Has it ever been considered? Would you have a few tips on what it might require?

pmackay avatar Feb 04 '16 17:02 pmackay

Aside from the railtie and some use of rails root in default initialisation it's not dependent on rails. The tests show how to override the default path so you should be able to use it just by setting the seeds_path.

I'm away from keyboard right now so there is an iirc attached to this reply.

james2m avatar Feb 04 '16 23:02 james2m

There are a couple of places this is dependent on Rails.root, I've tiptoed towards removing them in master, but would happily take pull requests to finish the job.

james2m avatar Aug 17 '16 18:08 james2m

@james2m I would try to make PR if you don't mind. But I don't know much about them gem internals so I need some time.

ivanovaleksey avatar Sep 01 '16 17:09 ivanovaleksey

Hey @ivanovaleksey master has some changes to make this easier. The main thing is get all references to Rails.root out of the code and just let the railtie.rb set the root.

james2m avatar Sep 01 '16 17:09 james2m

Thank you James! I will try to make it.

ivanovaleksey avatar Sep 01 '16 18:09 ivanovaleksey

James I have found in TODO.txt

Add generator for seeds directories

I know we can write Rails generator but if we make the gem framework agnostic (as you have wrote in TODO) would we still be able to make such generator for other frameworks?

ivanovaleksey avatar Sep 02 '16 11:09 ivanovaleksey

I wasn't really thinking about the rails generator as such, and the todo pre-dates generators moving into the rails command, I was just thinking of a simple rake task to create the directories probably db/seeds, db/seeds/development, db/seeds/test & db/seeds/production

james2m avatar Sep 02 '16 12:09 james2m

I see. Yeah some thing for fast start would be nice. If I solve this issue it would the next thing to do :relaxed:

ivanovaleksey avatar Sep 02 '16 12:09 ivanovaleksey

Just tried using it in a grape/rom app I am building and realised it was Rails specific.

Would love to have this Rails/AR agnostic.

Looking forward to Aleksey's PR getting merged.

wiggly avatar Feb 10 '17 00:02 wiggly

@wiggly @ivanovaleksey sorry I've been busy moving. I'm back on things this week. I'll finally get to look at the pull requests.

james2m avatar Feb 12 '17 03:02 james2m

@wiggly you should be able to use in your grape app now thanks to @ivanovaleksey, I don't have any non rails apps to test with, and we haven't got a stand alone environment in the test suite yet, so it would be good to hear how you get on with master.

james2m avatar Feb 12 '17 14:02 james2m

So, I have already started using @ivanovaleksey's PR code and it works for me.

I haven't yet played with different environments yet but the basics work and it doesn't trip up due to dependencies on Rails.

I will use master now instead and let you know if anything breaks but I don't expect it to.

I am using the http://rom-rb.org/ system for DB access, once I have tested it using correct seeds for different environments I could try and make a small example.

Right now all I am doing it extending the Seedbank::Runner class with a custome module that allows easy access to the ROM repositories I have set up.

wiggly avatar Feb 12 '17 19:02 wiggly

@wiggly @ivanovaleksey I've rolled this up into a 0.5.0.pre version.

james2m avatar Feb 13 '17 02:02 james2m

So, yeah, master also works fine as expected.

One question is whether you have thought about what to do about system enviornments. Since you can't rely on RAILS_ENV.

Right now I am building things from the ground up and I have my own env var to flag things that should be configured differently on an environment basis. Perhaps a Seedbank.env that could be set by users to choose the current environment? Then get the railtie to set this using Rails.env and allow others to set it in their own setup phases.

wiggly avatar Feb 13 '17 12:02 wiggly

That's an interesting point. I was thinking about pulling all the rails specific stuff out into its own module and letting that setup it's own prerequisites. I like the idea of Seedbank.env. @ivanovaleksey any thoughts on this?

james2m avatar Feb 14 '17 03:02 james2m

Sorry for the delay. I can't really tell anything which about that 😞 The idea of Seedbank.env seems to be nice for me too.

As I understand now the gem doesn't include any environment task in override_dependency list because of this, does it?

ivanovaleksey avatar Feb 15 '17 09:02 ivanovaleksey

So, I submitted a PR to enhance the rake tasks to allow people to set up their specific DB layer before the seeds get run, I could also take a shot at adding a way for people to easily select environments that is system-agnostic.

@ivanovaleksey Yes, that is exactly what would stop this right now.

wiggly avatar Feb 15 '17 11:02 wiggly

@wiggly thanks, I'll give it a poke over the weekend

james2m avatar Feb 17 '17 16:02 james2m