- 浏览: 1247844 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (729)
- Java_about (144)
- Spring_Hibernate_Struts_OpenSource (27)
- linux_unix (62)
- life_sth (21)
- js_css_html_xml_nodejs (69)
- design_pattens (1)
- Perl (8)
- php_ecshop (4)
- DB_Mysql_Oracle_Informix_SqlServer (43)
- JSTL (8)
- Testing_自动化测试 (42)
- DB_ID_UUID (4)
- SEM_SEO (1)
- english_study_improvement (4)
- SVN_Git (9)
- WebService_SOA_CloudComputing (3)
- E-Commerce (1)
- Lucene_Solr (7)
- others (2)
- Regex (2)
- tomcat_jetty (8)
- zeroc-ice (1)
- java_excel (5)
- ant_maven_gradle (5)
- Unity_VR_AR_C# (2)
- jmeter (1)
- XPath_dom4j (1)
- Ruby_and_Rails (68)
- write_a_rails (17)
- manage_and_team (1)
- getting_real (1)
- ubuntu (20)
- git_and_git_flow (7)
- TODO (1)
- PM_design (2)
- Python_and_Django (8)
- NoSql_mongo_redis (24)
- C/C++ (3)
- vi_vim_gvim (0)
- c#_.Net_windows编程_dll (10)
- Php_and_Yii (9)
- Android_IOS (31)
- Mysql (5)
- sa_运维_network_硬件 (37)
- lua (2)
- c_cpp_VisualStudio (21)
- 硬件-RM-Arduino (6)
最新评论
-
shenkun58:
...
NoClassDefFoundError: Could not initialize springframework.BeanCreationException -
liaojia1:
正解,感谢
NoClassDefFoundError: Could not initialize springframework.BeanCreationException -
flingfox63:
谢谢分享,电脑上有IPV6,导致了Guard启动不了……
ruby错误解决: Address family not supported by protocol - connect(2) -
c39274936:
s = "hello_world_ruby" ...
驼峰格式和下划线格式转换_translation between camel and snake format -
yfj300:
学习了学习了学习了学习了
硬盘基本知识(磁道、扇区、柱面、磁头数、簇、MBR、DBR)
周末看书,总想试验一把,可总不能跑到公司去吧~
所以,还得在win下安装一下ruby on rails
基本上按照这个步骤参考为http://rubyonrails.org/download
#1 安装ruby
1.8.7
#2 安装gem(好像1.9之后不用此步骤了)
1.8.5(公司用的1.3.7)
结果gem的1.8.5版本和rails2.3.8不兼容,下一篇写写gem的事情
#3 安装rails
2.3.8
D:\>gem install rails -v 2.3.8
Fetching: rake-0.9.2.gem (100%)
Fetching: activesupport-2.3.8.gem (100%)
Fetching: activerecord-2.3.8.gem (100%)
Fetching: rack-1.1.2.gem (100%)
Fetching: actionpack-2.3.8.gem (100%)
Fetching: actionmailer-2.3.8.gem (100%)
Fetching: activeresource-2.3.8.gem (100%)
Fetching: rails-2.3.8.gem (100%)
Successfully installed rake-0.9.2
Successfully installed activesupport-2.3.8
Successfully installed activerecord-2.3.8
Successfully installed rack-1.1.2
Successfully installed actionpack-2.3.8
Successfully installed actionmailer-2.3.8
Successfully installed activeresource-2.3.8
Successfully installed rails-2.3.8
8 gems installed
Installing ri documentation for rake-0.9.2...
Installing ri documentation for activesupport-2.3.8...
Installing ri documentation for activerecord-2.3.8...
Installing ri documentation for rack-1.1.2...
Installing ri documentation for actionpack-2.3.8...
Installing ri documentation for actionmailer-2.3.8...
Installing ri documentation for activeresource-2.3.8...
Installing ri documentation for rails-2.3.8...
Installing RDoc documentation for rake-0.9.2...
Installing RDoc documentation for activesupport-2.3.8...
Installing RDoc documentation for activerecord-2.3.8...
Installing RDoc documentation for rack-1.1.2...
Installing RDoc documentation for actionpack-2.3.8...
Installing RDoc documentation for actionmailer-2.3.8...
Installing RDoc documentation for activeresource-2.3.8...
Installing RDoc documentation for rails-2.3.8...
测试安装成功否:
D:\>rails -v
Rails 2.3.8
其他的包也大致安装吧。
#4 创建一个helloapp
1)装mysql数据库
2)生成一个database
mysql> create database hello;
3)安装mysql的gem包
D:\>gem install mysql
4)生成一个rails app
D:\workruby>rails helloapp
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create config/locales
create db
create doc
create lib
create lib/tasks
create log
create public/images
create public/javascripts
create public/stylesheets
create script/performance
create test/fixtures
create test/functional
create test/integration
create test/performance
create test/unit
create vendor
create vendor/plugins
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create Rakefile
create README
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create config/database.yml
create config/routes.rb
create config/locales/en.yml
create db/seeds.rb
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/new_rails_defaults.rb
create config/initializers/session_store.rb
create config/initializers/cookie_verification_secret.rb
create config/environment.rb
create config/boot.rb
create config/environments/production.rb
create config/environments/development.rb
create config/environments/test.rb
create script/about
create script/console
create script/dbconsole
create script/destroy
create script/generate
create script/runner
create script/server
create script/plugin
create script/performance/benchmarker
create script/performance/profiler
create test/test_helper.rb
create test/performance/browsing_test.rb
create public/404.html
create public/422.html
create public/500.html
create public/index.html
create public/favicon.ico
create public/robots.txt
create public/images/rails.png
create public/javascripts/prototype.js
create public/javascripts/effects.js
create public/javascripts/dragdrop.js
create public/javascripts/controls.js
create public/javascripts/application.js
create doc/README_FOR_APP
create log/server.log
create log/production.log
create log/development.log
create log/test.log
5)配置rails连接数据库
config/database.yml文件
此处为了简单测试,把test和production都配置成了一个,实际的项目应该分开~
development:
adapter: mysql
database: hello
pool: 5
timeout: 5000
username: root
password: fantaxy
host: localhost
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql
database: hello
pool: 5
timeout: 5000
username: root
password:
fantaxy
host: localhost
production:
adapter: mysql
database: hello
pool: 5
timeout: 5000
username: root
password:
fantaxy
host: localhost
6)写ActionPack
#I 在app/controllers目录下新建一个文件hello_controller.rb
class HelloController < ApplicationController
def index
@name = "fantaxy"
@now = Time.new
end
end
#II 在app/views目录下新建文件夹hello
#III 在app/views/hello下新建一个view文件index.html.erb
<html>
<head>
<title>hello</title>
</head>
<body>
<p>Hello <%= @name %></p>
<p>It's now <%= @now.to_s(:db) %></p>
</body>
</html>
7)启动server
D:\workruby\helloapp>ruby script\server
=> Booting WEBrick
=> Rails 2.3.8 application starting on http://0.0.0.0:3000
8)观察结果
浏览器输入:http://localhost:3000
看见rails的欢迎界面。
可以点击 About your application’s environment 连接看下自己主机的环境
如果有错误,看下后台,比如没有安装mysql的gem包等,会有提示
浏览器输入:http://localhost:3000/hello
看见结果:
Hello fantaxy
It's now 2011-07-02 22:35:24
先到此吧。记得找个自己喜欢的ide比较方便。
X
X
X
-
X
X
X
发表评论
-
ruby计算平方和开方_n次方n次幂
2022-06-28 21:52 504= = = ruby计算平方和开方 3 ** 2#= ... -
Ruby发送HTTP请求
2015-07-21 18:06 1087Ruby使用HTTP协议发送请求的方法备忘。 好像这 ... -
invalid byte sequence in GBK”问题 invalid byte sequence in UTF-8”问题
2015-07-03 15:11 2719碰见错误: test.rb:8:in `ma ... -
Ruby1.9之字符串内编码和外编码
2015-07-02 17:52 1200这里的文章很不错的么:Rubyist http://ru ... -
DevKit介绍和安装in railsInstaller
2015-05-26 17:01 2567DevKit介绍和安装in railsInstaller ... -
Rails_migrations中使用mysql的bigint
2014-09-30 14:32 928From:http://rubyer.me/blog/468 ... -
Rails外如何启动rails的类自动加载_activates autoloading using ActiveSupport 3.x
2016-06-22 12:08 550The following cod ... -
如何在rails里打开gem里面的类_为何有时候不生效
2014-09-02 21:55 881在rails里面打开某个gem的类,补充一下等等,也 ... -
ruby的加载机制和rails_自动加载机制_对比
2014-09-02 16:51 1487prefer:http://urbanautomat ... -
Rails源码阅读(13)rails中的autoload和ruby的autoload
2014-07-30 17:13 1850Rails源码阅读(13)rails中的autoload和 ... -
Rails中命名路由的区别***_url与***_path
2014-07-29 16:37 1010Rails中命名路由的区别***_url与***_path ... -
ruby_gem安装_切换指定不同的源
2014-07-20 18:09 1089from:http://www.hiceon.com/to ... -
Ruby 的文件操作_不断总结
2014-07-11 11:55 1086一、用文件和目 ... -
Rails源码阅读(12)叫Rails的模块module_Rails常量使用
2014-07-02 09:35 984The module nams "Rail ... -
注册邮件中的链接无host
2014-05-19 14:47 581在注册邮件中用命名路由的xxx_url不起作用,导致注 ... -
每个命令都有bundle exec的麻烦
2014-04-18 17:33 1345问题: 每次都得搞这个东西bundle exec放在 ... -
关于favicon.ico的报错:RoutingError
2014-03-31 14:45 1860错误: ActionController::Routin ... -
rbenv_安装太慢_解决办法
2014-03-31 13:51 2077rvm做了很多“不为人知”的事情,而且做的太 ... -
配置sunspot tomcat结合sunspot_rails
2014-02-26 10:58 795这个sunspot的东西还是有不少缺点的。 ht ... -
RubyOrRails_使用技巧_收集
2013-11-09 14:39 1004#link_to not working in sc ...
相关推荐
Redmine 搭建 Ruby_Ruby_on_Rails 项目管理系统
Ruby on Rails Guides v2 - Ruby on Rails 4.2.5
Ruby_on_Rails实践.rar
agile_web_development_with_rails_3rd_edition.9994652073.pdf
ruby_on_rails_3_入门教程(中文)
Ruby on Rails Guide:是rails官方教程,本人为了大家学习查阅的方便,制成chm格式。就如同java doc的chm格式一样方便。
Ruby on Rails 是无可非议的Ruby 杀手锏应用程序。它提供很多保障将Ruby 从其日文 本土的隐晦中解脱出来。没有其他任何一门编程语言可以以这样一个简单的Web应用程 序框架而自豪,该框架也吸取了大部分该语言开发者...
ruby_on_rails_创建一个博客项目.doc
ruby_on_rails 开发者实战 源代码上 1-12章 来之不易啊。仅供学习.
[Ruby_on_Rails][中文]_02._[Mac]_安裝Ruby_on_Rail_6.x
《Ruby_on_Rails敏捷开发最佳实践》英文版,文字影印版
这个是我从百度文库里找的rails笔记,原文作者用清晰的语言代领初学者怎样快速入门Rails
[Ruby_on_Rails][中文]_03._[Windows]_安裝Ruby_on_Rail_6.x
ruby开发环境使用rails安装部署指导手册.....................
[Ruby_on_Rails][中文][Rails_5.x]__03-2_._安裝不同版本的Rails與產生Rails_5.x版
Ruby.on.Rails.Enterprise.Application.Development
ruby rails radrails 环境 配置 图片加文字教你如何配置开发环境
Ruby on Rails Guides_ A Guide to Testing Rails Applications.pdf
Ruby.on.Rails.Tutorial,Learn.Web.Development.with.Rails,Third.Edition-中文版 文字版.pdf 个人收集电子书,仅用学习使用,不可用于商业用途,如有版权问题,请联系删除!
本书从Ruby和Rails的历史讲起,以在Rails框架上克隆故事共享网站digg.com为例,详细讲述了Ruby和Rails的安装过程、框架组成部分、与AJAX和Web 2.0技术结合、安全措施、高级话题和扩展功能等。本书带领读者运用最新...