"Go" installation and use of bootstrap in rails

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/lissdy/article/details/9195651seeing the front-end siege artists start using bootstrap to create Web pages, they also want to learn to use bootstrap in the rails they are learning recently.

The specific installation uses the following procedures:

1. Create Rails Engineering

Rails New Usedschool

2. Build Scaffolding

Rails g scaffold Item title:string Description:text--skip-stylesheets

3. Application migration

Rake Db:migrate

4. Modify the Gemfile file to add the bootstrap related package to be installed

5, install the relevant package

Bundle Install

Here I have a problem with the Ruby version limitation, and the bootstrap related package was successfully installed after Ruby was upgraded.

For specific upgrade actions, please see here: Ruby upgrade

6. Run Rails g bootstrap:install to generate bootstrap related files

So far, the bootstrap has been installed successfully, see below how to use

7. Modify the Application.html.erb layout file

This step to modify the template, after all, bootstrap specific usage is not familiar with, so direct take doctrine, to find a template to apply.

Template http://www.bootcss.com/examples/fluid.html

<! DOCTYPE html>"Application",: Media =" All"%> <%= Javascript_include_tag"Application"%> <%= csrf_meta_tags%>class="navbar navbar-inverse navbar-fixed-top"> <divclass="Navbar-inner"> <divclass="Container-fluid"> <button type="Button" class="btn Btn-navbar"data-toggle="collapse"data-target=". Nav-collapse"> <spanclass="Icon-bar"></span> <spanclass="Icon-bar"></span> <spanclass="Icon-bar"></span> </button> <aclass="Brand"href="#"> Two </a> <divclass="nav-collapse collapse"> <pclass="Navbar-text pull-right">loggedinchAs <a href="#" class="Navbar-link">Username</a> </p> <ulclass="nav"> <liclass="Active"><a href="#">Home</a></li> <li><a href="#about">About</a></li> <li><a href="#contact">Contact</a></li> </ul> </div><!--/.nav-collapse-</div&      Gt </div> </div> <divclass="Container-fluid"> <divclass="Row-fluid"> <divclass="span3"> <divclass="Well Sidebar-nav"> <ulclass="nav nav-list"> <liclass="Nav-header">Sidebar</li> <liclass="Active"><a href="#">Link</a></li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> <liclass="Nav-header">Sidebar</li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> <liclass="Nav-header">Sidebar</li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> </ul> </div><!--/.well--</div><!--/ Span--> <divclass="Span9"> <%=yield%> </div><!--/row--> </div><!--/span--> </div><!--/row--> Le JavaScript==================================================-<!--Placed at the end of the document so the pages load F Aster--<script src="//cdnjs.bootcss.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="//cdnjs.bootcss.com/ajax/libs/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script> </body>

 

8. Modify the item overall page style

Rails g bootstrap:themed items-f

Operation Result:

What's the swelling like? It's a lot better than the direct build of rails.

"Go" installation and use of bootstrap in rails

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.