Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an --editor option to ActiveRecord migration generator #5829

Closed

Conversation

subelsky
Copy link
Contributor

the first thing Rails devs do after running a migration is usually open that file in an editor. I added an --editor option here that does this for you automatically. I didn't see an easy way to test this (do the generators have their own tests?) but if there's a place where that should go, I'll gladly add them to this patch.

@timtyrrell
Copy link

I can dig it +1

@mperham
Copy link
Contributor

mperham commented Apr 13, 2012

🏩

@travisjeffery
Copy link

Even better to configure your editor such that you can generate your migration without ever having to leave it!

@hoenth
Copy link

hoenth commented Apr 13, 2012

+1

@oscardelben
Copy link
Contributor

+1

@travisjeffery that woud be an editor plugin.

@andrewle
Copy link

+1 <3

@soffes
Copy link

soffes commented Apr 14, 2012

It would be cool if you specified --editor with no value if it just used the $EDITOR in your shell.

@subelsky
Copy link
Contributor Author

@samsoffes that is how it operates, see the description for that option

@soffes
Copy link

soffes commented Apr 14, 2012

Ah :lazy_default => ENV['EDITOR'] missed that. Nice!

@nfm
Copy link

nfm commented Apr 15, 2012

+1

2 similar comments
@george
Copy link

george commented Apr 25, 2012

+1

@nerdEd
Copy link

nerdEd commented Apr 25, 2012

👍

@garygreyling
Copy link

Its like sitting in a room at dusk while it gets progressively darker, only for someone to walk in, flip a switch and have you realise whats been missing the past 2 hours! + 1 fo sho!

@shime
Copy link
Contributor

shime commented Apr 25, 2012

❤️

@jszmajda
Copy link

Probably best if you continue to return path from the method, otherwise awesome and useful :) +1

@waugh
Copy link

waugh commented Apr 26, 2012

+1

@steveklabnik
Copy link
Member

Oh man, I'm not sure how I feel about the particular solution to this problem, but I feel this pain every time I run rails g.

@subelsky
Copy link
Contributor Author

@steveklabnik I hear ya - is there a more general or useful way I should investigate? I'm not wedded to this implementation

@steveklabnik
Copy link
Member

I'll give it some thought, but I'm not sure, to be honest.

It's that it's different than every other generator that bugs me, the lack of symmetry. Then again, none of them do this...

@jmoline
Copy link

jmoline commented May 16, 2012

Anything that means I don't have to open my migrations folder (or worse, type in the file name datestamp) is a win.

+1

@jmoline
Copy link

jmoline commented May 16, 2012

That being said, I do understand @steveklabnik's objection. Maybe this doesn't belong in rails core, but would work better as a Guard gem that automatically opens any newly created file in the migrations folder?

I'm not just suggesting it so I can install and begin using it right away, either. Honest.

@oscardelben
Copy link
Contributor

I'm not sure about the lazy default though, it's not rare that I generate a migration and I run it right away.

Edit: maybe that's what it does already, I'm just not sure what lazy_default does.

@tilsammans
Copy link
Contributor

I want this every time I generate a migration.

What are the objections for not merging it, exactly? @steveklabnik I completely agree with you about the mess that is the various rails and rake commands. However, that does not invalidate this simple patch.

@tenderlove any chance this gets pulled in?

@rafaelfranca
Copy link
Member

I think that this can be pulled in but I want to propose get this is a higher level. We can define this option in every generator and open the lead file from it.

For example:

To a controller generator we can open the controller file. Same with models, resources, etc.

@subelsky can you change it?

@tilsammans
Copy link
Contributor

Agreed, that would be useful.

@rafaelfranca
Copy link
Member

2 months without any answer, so I'm closing this one. Feel free to open a new request with the changes that I required.

@subelsky
Copy link
Contributor Author

@rafaelfranca sorry, I did not see your request from two months ago. I'll get on it this week.

@ndbroadbent
Copy link
Contributor

Hi, I've opened a new pull request at #8553, which opens all generated files, instead of just migrations.

@ndbroadbent
Copy link
Contributor

Hi all, if you want to use the --editor option in your Rails 3 app, you can run this command from your app directory:

curl https://gist.github.com/raw/4342095/rails -o script/rails

(Since Rails 3 isn't accepting new features.)

See my blog post if you want to use it globally for all Rails 3 apps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet