摘要: 5.1 添加一些结构$ vim app/views/layouts/application.html.erb true %> true %> ... 阅读全文
posted @ 2013-12-04 18:22 salembe 阅读(249) 评论(0) 推荐(0) 编辑
摘要: 5.2 Sass和asset pipeline5.2.1 Asset pipelineAsset pipeline对Rails做了很多改动,但对Rails开发者只需要了解:资源目录,清单文件,预处理器引擎。资源目录Rails 3.0之前,静态文件分别放在如下的public/目录中: ·public/stylesheets ·public/javascripts .public/images这些文件夹中的文件通过请求http://example.com/stylesheets等地质发送给浏览器,3.0之后的版本也可以这么做从Rails3.1开始到Rails 4,静态文件存放在 阅读全文
posted @ 2013-12-04 18:22 salembe 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 4.1 导言定义full_title帮助方法$ vim app/helpers/application_helper.rbmodule ApplicationHelper def full_title(page_title) base_title = "Ruby on Rails Tutorial Sample App" if page_title.empty? base_title else "#{base_title} | #{page_title}" end end... 阅读全文
posted @ 2013-12-04 18:19 salembe 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 重构3.3 有点儿动态内容的页面rails new命令创建了布局文件,暂时重命名。$ mv app/views/layouts/application.html.erb foobar添加标题测试:$ vim spec/requests/static_pages_spec.rbrequire 'spec_helper'describe "Static pages" do describe "Home page" do it "should have the content 'Sample App'" do 阅读全文
posted @ 2013-11-27 16:00 salembe 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 新建项目:cd ~/rails_projectsrails new sample_app --skip-test-unitcd sample_app添加gem:group :development,:test do gem 'sqlite3' gem 'rspec-rails','2.13.1'endgroup :test do gem 'selenium-webdriver','2.0.0' gem 'capybara','2.1.0'endgroup :production do 阅读全文
posted @ 2013-11-27 14:07 salembe 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 运行rails new生成一个新程序:mkdir rails_projectscd rails_projectsrails new first_app修改一下Gemfile配置,然后执行bundle updatebundle install更新gem,然后可以查看本机网页了:rails server提示:`autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::Runtime 阅读全文
posted @ 2013-11-25 21:55 salembe 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 安装环境:系统Ubuntu安装完成之后,打开终端。首先设置一下源备份源sudo cp /etc/apt/sources.list /etc/apt/sources.list_backupvim打开 /etc/apt/sources.listsudo vim /etc/apt/sources.list... 阅读全文
posted @ 2013-11-24 20:21 salembe 阅读(178) 评论(0) 推荐(0) 编辑