Skip to content

Instantly share code, notes, and snippets.

@fakestarbaby
Created December 8, 2013 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fakestarbaby/7859239 to your computer and use it in GitHub Desktop.
Save fakestarbaby/7859239 to your computer and use it in GitHub Desktop.
Rails アプリケーションテンプレート超意訳 ref: http://qiita.com/fakestarbaby/items/01c46a273725d0a48b36
$ rails new blog -m ~/template.rb
$ rails new blog -m http://example.com/template.rb
$ rake rails:template LOCATION=~/template.rb
$ rake rails:template LOCATION=http://example.com/template.rb
rakefile("bootstrap.rake") do
<<-TASK
namespace :boot do
task :strap do
puts "i like boots!"
end
end
TASK
end
generate(:scaffold, "person", "name:string", "address:text", "age:number")
run "rm README.rdoc"
rake "db:migrate"
rake "db:migrate", env: 'production'
route "root to: 'person#index'"
inside('vendor') do
run "ln -s ~/commit-rails/rails rails"
end
lib_name = ask("What do you want to call the shiny library ?")
lib_name << ".rb" unless lib_name.index(".rb")
lib lib_name, <<-CODE
class Shiny
end
CODE
rake("rails:freeze:gems") if yes?("Freeze rails gems?")
# no?(question) acts just the opposite.
git :init
git add: "."
git commit: "-a -m 'Initial commit'"
gem "bj"
gem "nokogiri"
run_bundle
bundle install
gem_group :development, :test do
gem "rspec-rails"
end
add_source "http://code.whytheluckystiff.net"
environment 'config.action_mailer.default_url_options = {host: "http://yourwebsite.example.com"}', env: 'production'
initializer 'bloatlol.rb', <<-CODE
class Object
def not_nil?
!nil?
end
def not_blank?
!blank?
end
end
CODE
file 'app/components/foo.rb', <<-CODE
class Foo
end
CODE
generate(:scaffold, "person name:string")
route "root to: 'people#index'"
rake("db:migrate")
git :init
git add: "."
git commit: %Q{ -m 'Initial commit' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment