Skip to content

Instantly share code, notes, and snippets.

@yalab
Last active December 22, 2015 12:29
Show Gist options
  • Save yalab/6473131 to your computer and use it in GitHub Desktop.
Save yalab/6473131 to your computer and use it in GitHub Desktop.
Rails template for use bower-rails and bootstrap3.
options = @options.dup
options['skip_bundle'] = true
@options = options
gsub_file 'Gemfile', 'jquery-rails', 'bower-rails'
file 'Bowerfile', <<-CODE
asset 'jquery'
asset 'jquery-ujs'
asset 'bootstrap', '>= 3.0.0'
CODE
'app/assets/javascripts/application.js'.tap{|_|
gsub_file _, 'jquery_ujs', 'jquery-ujs/src/rails'
insert_into_file _, "//= require bootstrap\n", after: "//= require turbolinks\n"
}
'app/assets/stylesheets/application.css'.tap{|_|
insert_into_file _, " *= require bootstrap\n", after: " *= require_self\n"
append_to_file _, 'body { padding-top: 50px; }'
}
'app/views/layouts/application.html.erb'.tap{|_|
gsub_file _, /(<%= yield %>)/, <<-EOS.gsub(/^ /, '')
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">#{app_name}</a>
</div>
</div>
</div>
<div class="container">
\\1
</div>
EOS
insert_into_file _, <<-EOS.gsub(/^ /, "\n"), after: '</title>'
<meta name="viewport" content="width=device-width, initial-scale=1.0">
EOS
}
run 'bundle install'
rake "bower:install"
append_to_file '.gitignore', '/vendor/assets/bower_components'
application %{ config.assets.paths << Rails.root.join('vendor', 'assets', 'bower_components', '*') }
generate(:controller, "root", "index")
route "root 'root#index'"
git :init
git add: "."
git commit: %{ -m 'First commit' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment