Skip to content

Instantly share code, notes, and snippets.

@jcasimir
Created March 22, 2012 14:54
Show Gist options
  • Save jcasimir/2158793 to your computer and use it in GitHub Desktop.
Save jcasimir/2158793 to your computer and use it in GitHub Desktop.
Rake Instead of Rails
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$
#!/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
@marktabler
Copy link

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