在rails3项目中使用twitter-bootstrap-rails

阅读文章之前,确保你已经了解了twitter-bootstrap-rails,在这里:https://github.com/seyhunak/twitter-bootstrap-rails

 

 

基本步骤

在railscasts中有视频:http://railscasts.com/episodes/328-twitter-bootstrap-basics

 

说说步骤:

1.新建rails项目 rails new demo

2.修改gemfile文件 添加 gem 'twitter-bootstrap-rails'

3.运行bundle,加载所有的gem

4.进行自己的项目,比如,这里我们创建一个脚手架 rails g scaffold post title:string content:text --skip-stylesheets(因为我们要用自己的风格)

5.rake db:migrate

6.安装twitter-bootstrap-rails,命令:rails g bootstrap:install

7.使用全局的bootstrap:rails g bootstrap:layout application fixed(我们使用这种布局)

8.对某个action使用主题: rails g bootstrap:themed post -f(表示强制使用)

 

到这里,基本上就完成了twitter-bootstrap-rails的使用

 

 

使用flash

下面,说说在twitter-bootstrap-rails上使用flash的功能

付费视频在这里:http://railscasts.com/episodes/329-more-on-twitter-bootstrap

我自己也没看,等RoR学的差不多了,再去买,railscasts真心做的很不错,瑞恩真心牛逼啊

说说我自己找到的方法吧

 

1.找到application. html.erb在layout下面,这也就是我们上面创建的全局模板,

2.找到container这个class

在其内部添加这段代码

    <% flash.each do |name, msg| %>

      <div class="alert alert-<%= name == :notice ? "success" : "error" %>">

        <a class="close" data-dismiss="alert">×</a>

        <%= msg %>

      </div>

    <% end %>

    保存,并刷新页面,就可以看到flash信息了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值