-
Notifications
You must be signed in to change notification settings - Fork 8
Bootstrap
JP Barbosa edited this page Jul 23, 2015
·
7 revisions
echo "gem 'bootstrap-sass', '~> 3.3.5'" >> Gemfile
bundle install
rails g simple_form:install --bootstrap
rails s
echo "//= require bootstrap-sprockets" >> app/assets/javascripts/application.js
rm app/assets/stylesheets/application.css
nano app/assets/stylesheets/application.scss
@import "bootstrap-sprockets";
@import "bootstrap";
nano app/views/layouts/application.html.erb
<nav class="navbar navbar-inverse">
<div class="container">
<div id="navbar">
<ul class="nav navbar-nav">
<%= link_to('Rails Apz', '/', class: 'navbar-brand') %>
<li><%= link_to('Articles', articles_path) %></li>
<li><%= link_to('Authors', authors_path) %></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<%= yield %>
</div>
rails g controller Welcome index --no-helper --no-assets --no-test-framework
nano config/routes.rb
Rails.application.routes.draw do
root 'welcome#index'
nano app/views/welcome/index.html.erb
<div class="jumbotron">
<h1>Rails Apz</h1>
<p>The guide to build a Rails app from a to z.</p>
<p>
<a class="btn btn-lg btn-primary" href="https://github.com/jp7internet/rails-apz" role="button">View On GitHub</a>
</p>
</div>
nano app/views/articles/index.html.erb;nano app/views/authors/index.html.erb
<table class="table">
<%= link_to 'New Author', new_author_path, class: 'btn btn-primary' %>
<%= link_to 'New Article', new_article_path, class: 'btn btn-primary' %>
nano app/views/articles/_form.html.erb;nano app/views/authors/_form.html.erb
<%= f.button :submit, class: 'btn btn-primary' %>
nano app/views/layouts/_flash.html.erb
<% flash.each do |name, msg| %>
<%= content_tag :div, msg, class: "alert alert-#{name == 'notice' ? 'info' : name}" %>
<% end %>
nano app/views/articles/index.html.erb; \
nano app/views/articles/show.html.erb; \
nano app/views/authors/index.html.erb; \
nano app/views/authors/show.html.erb
<%= render 'layouts/flash' %>
<!-- <p id="notice"><%= notice %></p> -->
open http://localhost:3000/articles
open http://localhost:3000/articles/new
git add .
git commit -m "Add Bootstrap"