摘要:
2. 使用脚手架快速搭建网页rails的脚手架可以快速生成应用程序的一些片段,如果你需要为一个资源创建一系列的控制器视图模型,那么脚手架就是你需要的工具3. 创建资源对于一个博客程序,你可以以生成一个Post资源脚手架开始:$ rails g scaffold post name:string title:string content:text 该命令将为你构建15个文件:文件 说明db/migrate/20101122214725_create_posts.rb创建posts表的迁移任务 (你的文件名称将包括一个不同的时间戳)app/models/post.rbPost 模型test/fi. 阅读全文
posted @ 2014-01-20 22:54
怒杀神
阅读(360)
评论(0)
推荐(0)
摘要:
构建rails项目--blog$ rails new blog --skip-bundle$ cd blog$ bundle --local$ bundle install #安装需要的包$ rake db:create #创建数据库$ rails s #启动服务器 Hello Rails$ rails g controller home index修改app/views/home/index.html.erb文件内容Hello, Rails如果有删除public/index.html修改config/routes.rb(应用程序路由设置)Blog::Application.routes.d. 阅读全文
posted @ 2014-01-20 22:26
怒杀神
阅读(251)
评论(0)
推荐(0)
摘要:
在浏览器中使用127.0.0.1:3000来访问 阅读全文
posted @ 2014-01-20 21:24
怒杀神
阅读(302)
评论(0)
推荐(0)
摘要:
现象:D:\>rails new work/demo cd work/demo D:\work\demo>ruby script/server 这时显示出错: ruby: No such file or directory -- script/server (LoadError) 解决办法:3.0直接用rails server 阅读全文
posted @ 2014-01-20 21:20
怒杀神
阅读(383)
评论(0)
推荐(0)
摘要:
在配置好ruby的win 7 命令行下运行,gem install rails 安装成功之后会收到提示,下面就可以用rails建立项目了。为了提高“rails new”时“bundle install”的速度,可以使用下面的技巧rails new my_app --skip-bundlecd my_appbundle install --local 阅读全文
posted @ 2014-01-20 21:17
怒杀神
阅读(135)
评论(0)
推荐(0)
摘要:
在新建rails项目时,rails new老是卡在bundle install那里,少则五分钟,多则几十分。这是因为rails new时自动会运行bundle install,而bundle install会自动去rubygems.org查找是否有更新。但需要的gems我早安装好了,且不用更新,所以上面步骤就可省了。强烈建议rails党委取消rails new时自动查找gems更新功能!解法很简单rails new my_app --skip-bundlecd my_appbundle install --local另外,最新版bundler速度提高不少,建议使用,也能提速gem instal 阅读全文
posted @ 2014-01-20 21:17
怒杀神
阅读(451)
评论(0)
推荐(0)

浙公网安备 33010602011771号