Make Rails App Template CD to root and run bundle commands?
-
30-05-2021 - |
Question
I'm sure you can appreciate this attempt at laziness: I would like to improve my app template script in Rails 3.2.
I do something like
rails new APPNAME -m path/to/template.rb
I would like to update the script to allow me to cd
into the new application so I can run bundle exec COMMAND
?
For example,
if compass = yes?("Would you like to install Compass and Susy?")
gem_group :assets do
gem 'compass-rails'
gem 'compass-susy-plugin'
end
if compass == true
run "bundle install"
inside "#{Rails.application.class.parent_name}" do
run "bundle exec compass install susy"
end
end
end
When I run the above code I get an error like -
unexpected keyword_do_block (SyntaxError)
/home/rhodee/GitRepos/dotfiles/workflow.rb:103: syntax error, unexpected keyword_end, expecting $end
Thank you for enabling my lazy.
Solution
You should be able to remove the "inside" and simply execute
run "bundle exec compass install susy"
To actually move inside a directory and do something, you could:
run "cd #{Rails.application.class.parent_name}/public; rm index.html"
(Of course you could have run the above as run "rm public/index.html" but that's not the point.)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow