Created
March 22, 2012 14:54
-
-
Save jcasimir/2158793 to your computer and use it in GitHub Desktop.
Rake Instead of Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jsblogger_advanced$ rake generate model Moderator username:string | |
invoke active_record | |
create db/migrate/20120322145332_create_moderators.rb | |
create app/models/moderator.rb | |
invoke rspec | |
create spec/models/moderator_spec.rb | |
jsblogger_advanced$ rake destroy model Moderator | |
invoke active_record | |
remove db/migrate/20120322145332_create_moderators.rb | |
remove app/models/moderator.rb | |
invoke rspec | |
remove spec/models/moderator_spec.rb | |
jsblogger_advanced$ rake server | |
=> Booting WEBrick | |
=> Rails 3.2.1 application starting in development on http://0.0.0.0:3000 | |
=> Call with -d to detach | |
=> Ctrl-C to shutdown server | |
[2012-03-22 10:53:51] INFO WEBrick 1.3.1 | |
[2012-03-22 10:53:51] INFO ruby 1.9.2 (2012-02-14) [x86_64-darwin11.3.0] | |
[2012-03-22 10:53:51] INFO WEBrick::HTTPServer#start: pid=14209 port=3000 | |
^C[2012-03-22 10:53:53] INFO going to shutdown ... | |
[2012-03-22 10:53:53] INFO WEBrick::HTTPServer#start done. | |
Exiting | |
jsblogger_advanced$ rake console | |
Loading development environment (Rails 3.2.1) | |
1.9.2-p318 :001 > exit | |
jsblogger_advanced$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env rake | |
# Add your own tasks in files placed in lib/tasks ending in .rake, | |
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | |
require File.expand_path('../config/application', __FILE__) | |
JsbloggerCodemash::Application.load_tasks | |
[:generate, :destroy, :server, :console].each do |command| | |
desc "Proof-of-concept proxy to the rails CLI" | |
task command do | |
system("rails #{command} #{ARGV[1..-1].join(' ')}") | |
exit | |
end | |
end |
I have been very disappointed that rake server
didn't work, so I like this
A thousand times, yes.
Does this confuse the distinction between Rake as an independent tool from Rails as an independent tool? More specifically, do newcomers skip over the power of using Rake exclusively with Ruby and just associate it as a Rails tool?
I'd love to hear the motivation behind the idea. What pains are you trying to alleviate with it?
It does feel arbitrary that I start a server with rails server
but I migrate the database my server depends on with rake db:migrate
. I'm in favor.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
+1 the usage of rake for some things but rails for others is inconsistent and could be tightened up