惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Hacker News
The Hacker News
F
Full Disclosure
Cloudbric
Cloudbric
Blog — PlanetScale
Blog — PlanetScale
W
WeLiveSecurity
N
News and Events Feed by Topic
T
Troy Hunt's Blog
V2EX - 技术
V2EX - 技术
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
B
Blog
GbyAI
GbyAI
C
Check Point Blog
B
Blog RSS Feed
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Recorded Future
Recorded Future
The Last Watchdog
The Last Watchdog
N
News and Events Feed by Topic
T
The Blog of Author Tim Ferriss
O
OpenAI News
V
V2EX
人人都是产品经理
人人都是产品经理
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
WordPress大学
WordPress大学
www.infosecurity-magazine.com
www.infosecurity-magazine.com
S
Security @ Cisco Blogs
C
Cisco Blogs
Security Latest
Security Latest
S
Security Affairs
V
Visual Studio Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
Last Week in AI
Last Week in AI
AWS News Blog
AWS News Blog
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
PCI Perspectives
PCI Perspectives
博客园_首页
U
Unit 42
Google DeepMind News
Google DeepMind News
Hugging Face - Blog
Hugging Face - Blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
The Register - Security
The Register - Security
N
Netflix TechBlog - Medium
L
LINUX DO - 热门话题
H
Hacker News: Front Page

博客园 - 疾行者

关于开发ActiveX 控件的安装问题 [转]安卓巴士Android开发神贴整理 偶然发现5年前的编程实习日记,特与博客园同仁分享一下 实现客户端的DataSet - 疾行者 - 博客园 AutoIt应用技巧示例[转] - 疾行者 - 博客园 [导入]Linq学习笔记(1.7)——First、ElementAt、Any、all [导入]Linq学习笔记(1.8)——Count、Sum、Min、Max、Average [导入]Linq学习笔记(2.1)——初识 DLinq [导入]Linq学习笔记(2.2)——深入DLinq查询 [导入]Linq学习笔记(2.3)——DLinq高级操作 NHibernate 多主键设置 - 疾行者 - 博客园 c#的一些技巧 - 疾行者 - 博客园 人的一生,到底在追求甚么?... XP 风格的可拖动列、可排序、可改变宽度的DataGrid的例子 webservice结合dthml的简单例子(二,dhtml) 文件的上传下载 asp.net访问组件失败,请在web.,config中加 数字转化成大写类 javascript小技巧&&JavaScript[对象.属性]集锦 [转载了多篇]
Ruby On Rails 安装手记
疾行者 · 2011-07-29 · via 博客园 - 疾行者

弄了好几天,Ror环境终于搭好了,为了防止以后忘记,少走弯路,特记录下

=============================================

安装过程

1、安装 rubyinstaller-1.9.2

2、安装 执行  gem install rails

3、安装  dev kit 下载后 解压到ruby 的安装目录

4、安装Netbeans 6.9.1

5、打开Netbeans 配置  Ruby 的gem 重点 mysql2 0.2.6 让ror 支持 mysql

6、安装 ruby_debug_ide (还没有搞定,一直报错)

开发过程

1、创建项目 (Blog)

2、配置database.yam

3、执行rake  任务 db:create (会根据database.yam 在mysql 中创建数据库,不用去手动创建数据库)

4、启动服务,打开页面,看是否正常 尤其是看环境变量是否正正确显示

5、创建 controller  home index

6、打开服务 http://127.0.0.1:3000/home/index 看是否正常

7、更改默认主页 (1、删除public\index.html  2、更改routes 中的 root :to => "home#index")

8、创建脚手架模型( generate scaffold Post name:string title:string content:text)

9、执行 rake 任务,将新的数据模型同步到数据库中 rake db:migrate

10、在首页上 增加 到脚手架的链接 (在 views\home\index.html.erb 中修改为

<h1>Hello, Rails!</h1> <%= link_to "My Blog"posts_path %> 

注意里面的 posts_path,约定的写法

11、打开首页http://127.0.0.1:3000/ 看到有到blog的超级链接

12、连进去进行CURD测试。

13、在模型文件中增加验证信息

class Post < ActiveRecord::Base

  validates :name:presence => true

  validates :title, :presence => true,

                    :length => { :minimum => 5 }

end

presence 表示是否可为空,length 代表字段的长度

14、测试是否有验证信息显示。

15、创建一个普通model Comment (帖子评论)

$ rails generate model Comment commenter:string body:text post:references 

 注意 post:references

 16、在Post模型中自动生成了一对多的关系

class Comment < ActiveRecord::Base

  belongs_to :post

end

 17、执行 rake ,任务 将新的数据模型同步到数据库中 rake db:migrate

18、修改  Post 模型  增加一对多映射

class Post < ActiveRecord::Base

  validates :name:presence => true

  validates :title, :presence => true,

                    :length => { :minimum => 5 }

  has_many :comments

end

19、在 route 中配置 Comments映射(有待研究)

resources :posts do

  resources :comments

end

20、创建controller

$ rails generate controller Comments

 21、修改views/posts/show.html.erb,增加 对 Comment 的编辑

<p class="notice"><%= notice %></p>

<p>

  <b>Name:</b>

  <%= @post.name %>

</p>

<p>

  <b>Title:</b>

  <%= @post.title %>

</p>

<p>

  <b>Content:</b>

  <%= @post.content %>

</p>

<h2>Add a comment:</h2>

<%= form_for([@post, @post.comments.build]) do |f| %>

  <div class="field">

    <%= f.label :commenter %><br />

    <%= f.text_field :commenter %>

  </div>

  <div class="field">

    <%= f.label :body %><br />

    <%= f.text_area :body %>

  </div>

  <div class="actions">

    <%= f.submit %>

  </div>

<% end %>

<%= link_to 'Edit Post', edit_post_path(@post) %> |

<%= link_to 'Back to Posts', posts_path %> |

22、修改 commentcontroller

class CommentsController < ApplicationController

  def create

    @post = Post.find(params[:post_id])

    @comment = @post.comments.create(params[:comment])

    redirect_to post_path(@post)

  end

end

23、先写道这里了

具体参考 http://guides.rubyonrails.org/getting_started.html