如何在我的Rails 3.2.1应用程序中使用twitter-bootstrap-rails gem?什么是工作流程?
我做完之后:
rails g bootstrap:layout [LAYOUT_NAME] [*fixed or fluid] [options]
接下来我该怎么办?我只是将生成的代码复制并粘贴到我的视图中吗?我是否为每个视图都这样做?如果是这样,怎么做
rails g bootstrap:themed [RESOURCE_NAME] [LAYOUT] [options]
有什么不同吗?
你们甚至使用轨道发电机吗?
由于
答案 0 :(得分:46)
我是twitter-bootstrap-rails gem的作者。我将给你一个快速的步骤,介绍如何安装和使用twitter-bootstrap-rails。
Ruby堆栈; (Ruby 1.9.3,Rails 3.1或Rails 3.2是必需的。使用RVM开始)
将gem捆绑到Gemfile之后;
gem 'twitter-bootstrap-rails'
bundle install
rails g bootstrap:install
(它将包括Twitter Bootstrap到您应用的资产管道)
rails g bootstrap:layout application fixed
(它将为您生成布局,默认情况下为application.html.erb,将生成固定布局)
rails g scaffold post title:string description:text
(此步骤使用Rails生成器为您创建CRUD内容)
rake db:migrate
(迁移到数据库)
rails g bootstrap:themed posts
(适用于“帖子”视图和表单的Twitter Bootstrap兼容样式)
还有详细的安装文档,用法和生成器,coffeescript等。 https://github.com/seyhunak/twitter-bootstrap-rails
答案 1 :(得分:4)
有一个RailsCasts教程是一个很好的起点:
答案 2 :(得分:0)
执行命令
rails new APPLICATION -m anyfile.rb
anyfile.rb
gem "therubyracer"
gem "less-rails"
gem "twitter-bootstrap-rails"
generate("scaffold", "Post title:string content:text")
rake("db:create")
rake("db:migrate")
generate("bootstrap:layout", "application fluid")
generate("bootstrap:install")
generate("bootstrap:themed", "posts")
git :init
git :add => "."
git :commit => "-m First commit!"