- 浏览: 2049278 次
- 性别:
- 来自: NYC
文章分类
- 全部博客 (628)
- Linux (53)
- RubyOnRails (294)
- HTML (8)
- 手册指南 (5)
- Mysql (14)
- PHP (3)
- Rails 汇总 (13)
- 读书 (22)
- plugin 插件介绍与应用 (12)
- Flex (2)
- Ruby技巧 (7)
- Gem包介绍 (1)
- javascript Jquery ext prototype (21)
- IT生活 (6)
- 小工具 (4)
- PHP 部署 drupal (1)
- javascript Jquery sort plugin 插件 (2)
- iphone siri ios (1)
- Ruby On Rails (106)
- 编程概念 (1)
- Unit Test (4)
- Ruby 1.9 (24)
- rake (1)
- Postgresql (6)
- ruby (5)
- respond_to? (1)
- method_missing (1)
- git (8)
- Rspec (1)
- ios (1)
- jquery (1)
- Sinatra (1)
最新评论
-
dadadada2x:
user模型里加上 protected def email ...
流行的权限管理 gem devise的定制 -
Sev7en_jun:
shrekting 写道var pattern = /^(0| ...
强悍的ip格式 正则表达式验证 -
jiasanshou:
好文章!!!
RPM包rpmbuild SPEC文件深度说明 -
寻得乐中乐:
link_to其实就是个a标签,使用css控制,添加一个参数: ...
Rails在link_to中加参数 -
aiafei0001:
完全看不懂,不知所然.能表达清楚一点?
"$ is not defined" 的问题怎么办
Geez,在seemoon家看到了一个也说运行edge rails的说明那么
rails _2.2.0_myapp
和rake rails:freeze:edge TAG=rel_1-1-6
有什么不一样呢?
很简单,比如你有一个项目叫做multiapp,你的开发环境中有2.1,2.2,2.3三个rails版本,你想用2.2来开发:
rails _2.2.0_ multiapp
生成app时加入以下划线为头尾的版本号来指定rails版本。
http://lightyror.thegiive.net/2007/04/rails-version.html,以下為其原文內容。
目前使用 Rails 的網站,Version 分成好幾派。
0.X
1.0
1.1
1.2
Rails 0.X 的就是幾年前就開始在使用 Rails 的始祖,據我所知國內也是有網站還再用 0.X ,他們之所以死撐不換的原因只有一個,就是怕升級上去原本的 code 根本不相容。1.0 的時候我沒趕上,那可能要問一些長輩才知道 1.0 的模樣是怎麼樣子。
我進入 Rails 圈子剛好是 1.1 的剛剛出的時代,那時候 RJS 剛剛出來,大家叫好又叫座。我也因此全新投入了 Rails,1.1 的穩定度很高,速度也不賴。 Rails .12 是今年才出的,REST 加上 has_many :through 實在非常的吸引人,不過有 benchmark 表示 Rails 1.2 在速度上輸給 Rails 1.1,不過也沒輸太多。所以綜觀起來,要使用 Rails 1.1 或是 1.2 是要看你的需求而定的,沒有一定要使用那個版本的建議。
我現在手邊的 Project 都是用 1.1 ,而且絕大多數已經上線在跑的,短期間不太可能轉換到 1.2 。但是我一定會花很多時間在了解 1.2 的情況。也就是說,我希望能夠在我的機器上面裝 1.1 跟 1.2,有沒有辦法達成呢?
當然有,這很基本!!!
首先,你的 gem 已經安裝了你所要求的 Rails Version,像是我希望在我的機器上面可以自由使用 1.1 或是 1.2 的 Rails,所以我的 gem 安裝情況就是
rails (1.2.3, 1.1.6)
Web-application framework with template engine, control-flow layer,
and ORM.
問題來了,要怎麼一次安裝兩個以上的 version 呢?假設你的 Rails 已經安裝了 1.1.6 ,可是又要安裝 1.2.3 ,就這樣打吧。
sudo gem install -v=1.2.3 rails
當然,如果你想安裝的是最新的 Rails Release,那麼這樣也是可以的
sudo gem i rails
如此就可以在同一台機器上面安裝不同 version 的 rails 。
確定了你的 gem 已經安裝了多個 version,我們必須了較 freeze code 的概念,很多時候我們的某個 Project 的 code 是在某個版本的 rails 開發的。當rails 出了新的 release,原本run 好好的 code 就可能出現一堆 error,所以我們必須要在這個 Project 也包入 Rails 這個 version 的 code。使用方式如下
rake rails:freeze:edge TAG=rel_1-1-6
rake rails:freeze:edge TAG=rel_1-2-3
顧名思義,你可以再 TAG 下面指定你要的 Rails Version,這個指令會把 Rails 放入 vender/rails/ 底下,以後伺服器執行前,他都會去這個資料夾尋找,如果有 vender/rails/ 的資料夾,他就不會使用系統預設的 Rails version ,而是使用已經包在這個 Rails 資料夾的 version。
當然,如果我們將已經包好的 Rails Version 解除,重新使用系統預設的 Rails Version,就這樣打即可
rake rails:unfreeze
他做的事情其實就只是 rm -fr vender/rails/ 資料夾而已。
最後一點,如果你不確定你的 Rails Package 到底使用那個 Version 的 Rails ,你可以打入
ruby script/about
他會跟你講的一清二楚的。
Simplifying Edge Rails Setup
Post by Robert Evans
This entry is by Robert Evans, a fulltime Ruby/Rails developer. You can check out what he is doing over on his blog - http://robertrevans.com. He has several exciting projects that will be released within the next 2 months, so go check them out.
I am a huge fan of edge Rails and use it for every project that I work on. My only complaint about this great framework, is that I constantly have to do the same things over and over to setup my application. It can take a decent amount of time to create your directory, checkout edge Rails via subversion, run rails myproject using edge Rails, and then download all the wonderful plugins. Seriously, you could have a blog written in the amount of time that it takes to get everything setup and ready to go. So, we need to DRY up this process.
I’ve written a very simple shell script that does all the work for you. It’ll create a directory, download edge rails, create the edge project, setup the database.yml file, and get all the plugins I would normally use. And what do we need to do? Just type ./set_rails myprojectname postgres at the prompt and sit back and let it do the work for you.
Let’s take a walk through this script and see what it is actually doing and talk about some ideas that you can do to personalize it for you.
#!/bin/sh
clear
echo "Creating Rails Folder..."
mkdir -p $1/vendor
cd $1
echo "Downloading Edge Rails..."
svn export http://dev.rubyonrails.org/svn/rails/trunk vendor/rails
echo "Setting up Edge Rails Project..."
ruby vendor/rails/railties/bin/rails .
This is the first part of our shell script. As you can see it clears the prompt, gives you a message that it is creating a folder for you. It takes the name of that folder you passed when you typed *myprojectname* into the prompt as the first argument of the script call. That first argument is stored in $1 of our script and the second argument is stored in $2.
Next, we grab the latest edge Rails from the svn server and run the command to setup our rails application. You may be more used to seeing/doing rails myprojectname, but for edge Rails, we run ruby vendor/rails/railties/bin/rails . to create our project on edge rails.
echo "I'm going to remove the README file and add a CHANGELOG file..."
rm README
touch CHANGELOG
echo "Removing the public/index.html file..."
rm public/index.html
echo "Creating the config/database.yml.sample file..."
touch config/database.yml.sample
echo "login: &login
adapter: $2
host: localhost
username:
password:
development:
database: $1_dev
<<: *login
test:
database: $1_test
<<: *login
production:
database: $1_production
<<: *login" > config/database.yml.sample
echo "Editing the database.yml file..."
cp config/database.yml.sample config/database.yml
echo "Creating the app/views/layout/application.rhtml file..."
touch app/views/layouts/application.rhtml
echo "Creating the public/stylesheets/screen.css file..."
touch public/stylesheets/screen.css
This snippet does a few things: removes some files, creates a sample YAML file for our db to be checked into Subversion and also adds our database information to that YAML file and then copies the sample YAML file contents over to the database.yml file.
The database YAML file takes the second argument you passed via the script call, postgres, and uses it as the adapter value telling our application that we are using that specific database program for this application. So you could pass postgres, mysql, sqlite or whatever database you are using. Also, the first argument is used to setup the names of our development, test and production databases.
Here is an instance where you could add your username and password for your development database and not worry about having to open that file again to set it. We then create an application.rhtml file within our app/views/layouts directory and a stylesheet file called screen.css. I also never use the README file that is installed by default, so I remove that and add the CHANGELOG file. This has been a great to keep a text based account of what you have completed and/or need to complete for this specific project. Works well within teams.
clear
echo "Adding an assortment of plugins..."
./script/plugin install http://svn.techno-weenie.net/projects/plugins/restful_authentication/
./script/plugin install http://svn.techno-weenie.net/projects/plugins/acts_as_versioned/
./script/plugin install http://svn.techno-weenie.net/projects/plugins/acts_as_paranoid/
./script/plugin install http://svn.techno-weenie.net/projects/plugins/acts_as_attachment/
............
This is where a lot of time can be taken up: installing plugins. Nothing fancy here, just some plugins being installed.
RaPT, being worked on by Geoffrey Grosenbach, has the nice addition of plugin packs, thanks to Luke Redpath, which would be a nice replacement here in the script. In the future, I’ll be changing the installation of plugins over to a RaPT plugin pack so that it is generic enough to install whatever plugins you have in your own pack.
There is one last snippet of code, but it is just letting you know your edge Rails application has been made and sends you off with a ‘Happy Programming!’.
You can download this script off my website, here as set_rails.zip
Happy Programming!
Robert Evans
rails _2.2.0_myapp
和rake rails:freeze:edge TAG=rel_1-1-6
有什么不一样呢?
很简单,比如你有一个项目叫做multiapp,你的开发环境中有2.1,2.2,2.3三个rails版本,你想用2.2来开发:
rails _2.2.0_ multiapp
生成app时加入以下划线为头尾的版本号来指定rails版本。
http://lightyror.thegiive.net/2007/04/rails-version.html,以下為其原文內容。
目前使用 Rails 的網站,Version 分成好幾派。
0.X
1.0
1.1
1.2
Rails 0.X 的就是幾年前就開始在使用 Rails 的始祖,據我所知國內也是有網站還再用 0.X ,他們之所以死撐不換的原因只有一個,就是怕升級上去原本的 code 根本不相容。1.0 的時候我沒趕上,那可能要問一些長輩才知道 1.0 的模樣是怎麼樣子。
我進入 Rails 圈子剛好是 1.1 的剛剛出的時代,那時候 RJS 剛剛出來,大家叫好又叫座。我也因此全新投入了 Rails,1.1 的穩定度很高,速度也不賴。 Rails .12 是今年才出的,REST 加上 has_many :through 實在非常的吸引人,不過有 benchmark 表示 Rails 1.2 在速度上輸給 Rails 1.1,不過也沒輸太多。所以綜觀起來,要使用 Rails 1.1 或是 1.2 是要看你的需求而定的,沒有一定要使用那個版本的建議。
我現在手邊的 Project 都是用 1.1 ,而且絕大多數已經上線在跑的,短期間不太可能轉換到 1.2 。但是我一定會花很多時間在了解 1.2 的情況。也就是說,我希望能夠在我的機器上面裝 1.1 跟 1.2,有沒有辦法達成呢?
當然有,這很基本!!!
首先,你的 gem 已經安裝了你所要求的 Rails Version,像是我希望在我的機器上面可以自由使用 1.1 或是 1.2 的 Rails,所以我的 gem 安裝情況就是
rails (1.2.3, 1.1.6)
Web-application framework with template engine, control-flow layer,
and ORM.
問題來了,要怎麼一次安裝兩個以上的 version 呢?假設你的 Rails 已經安裝了 1.1.6 ,可是又要安裝 1.2.3 ,就這樣打吧。
sudo gem install -v=1.2.3 rails
當然,如果你想安裝的是最新的 Rails Release,那麼這樣也是可以的
sudo gem i rails
如此就可以在同一台機器上面安裝不同 version 的 rails 。
確定了你的 gem 已經安裝了多個 version,我們必須了較 freeze code 的概念,很多時候我們的某個 Project 的 code 是在某個版本的 rails 開發的。當rails 出了新的 release,原本run 好好的 code 就可能出現一堆 error,所以我們必須要在這個 Project 也包入 Rails 這個 version 的 code。使用方式如下
rake rails:freeze:edge TAG=rel_1-1-6
rake rails:freeze:edge TAG=rel_1-2-3
顧名思義,你可以再 TAG 下面指定你要的 Rails Version,這個指令會把 Rails 放入 vender/rails/ 底下,以後伺服器執行前,他都會去這個資料夾尋找,如果有 vender/rails/ 的資料夾,他就不會使用系統預設的 Rails version ,而是使用已經包在這個 Rails 資料夾的 version。
當然,如果我們將已經包好的 Rails Version 解除,重新使用系統預設的 Rails Version,就這樣打即可
rake rails:unfreeze
他做的事情其實就只是 rm -fr vender/rails/ 資料夾而已。
最後一點,如果你不確定你的 Rails Package 到底使用那個 Version 的 Rails ,你可以打入
ruby script/about
他會跟你講的一清二楚的。
Simplifying Edge Rails Setup
Post by Robert Evans
This entry is by Robert Evans, a fulltime Ruby/Rails developer. You can check out what he is doing over on his blog - http://robertrevans.com. He has several exciting projects that will be released within the next 2 months, so go check them out.
I am a huge fan of edge Rails and use it for every project that I work on. My only complaint about this great framework, is that I constantly have to do the same things over and over to setup my application. It can take a decent amount of time to create your directory, checkout edge Rails via subversion, run rails myproject using edge Rails, and then download all the wonderful plugins. Seriously, you could have a blog written in the amount of time that it takes to get everything setup and ready to go. So, we need to DRY up this process.
I’ve written a very simple shell script that does all the work for you. It’ll create a directory, download edge rails, create the edge project, setup the database.yml file, and get all the plugins I would normally use. And what do we need to do? Just type ./set_rails myprojectname postgres at the prompt and sit back and let it do the work for you.
Let’s take a walk through this script and see what it is actually doing and talk about some ideas that you can do to personalize it for you.
#!/bin/sh
clear
echo "Creating Rails Folder..."
mkdir -p $1/vendor
cd $1
echo "Downloading Edge Rails..."
svn export http://dev.rubyonrails.org/svn/rails/trunk vendor/rails
echo "Setting up Edge Rails Project..."
ruby vendor/rails/railties/bin/rails .
This is the first part of our shell script. As you can see it clears the prompt, gives you a message that it is creating a folder for you. It takes the name of that folder you passed when you typed *myprojectname* into the prompt as the first argument of the script call. That first argument is stored in $1 of our script and the second argument is stored in $2.
Next, we grab the latest edge Rails from the svn server and run the command to setup our rails application. You may be more used to seeing/doing rails myprojectname, but for edge Rails, we run ruby vendor/rails/railties/bin/rails . to create our project on edge rails.
echo "I'm going to remove the README file and add a CHANGELOG file..."
rm README
touch CHANGELOG
echo "Removing the public/index.html file..."
rm public/index.html
echo "Creating the config/database.yml.sample file..."
touch config/database.yml.sample
echo "login: &login
adapter: $2
host: localhost
username:
password:
development:
database: $1_dev
<<: *login
test:
database: $1_test
<<: *login
production:
database: $1_production
<<: *login" > config/database.yml.sample
echo "Editing the database.yml file..."
cp config/database.yml.sample config/database.yml
echo "Creating the app/views/layout/application.rhtml file..."
touch app/views/layouts/application.rhtml
echo "Creating the public/stylesheets/screen.css file..."
touch public/stylesheets/screen.css
This snippet does a few things: removes some files, creates a sample YAML file for our db to be checked into Subversion and also adds our database information to that YAML file and then copies the sample YAML file contents over to the database.yml file.
The database YAML file takes the second argument you passed via the script call, postgres, and uses it as the adapter value telling our application that we are using that specific database program for this application. So you could pass postgres, mysql, sqlite or whatever database you are using. Also, the first argument is used to setup the names of our development, test and production databases.
Here is an instance where you could add your username and password for your development database and not worry about having to open that file again to set it. We then create an application.rhtml file within our app/views/layouts directory and a stylesheet file called screen.css. I also never use the README file that is installed by default, so I remove that and add the CHANGELOG file. This has been a great to keep a text based account of what you have completed and/or need to complete for this specific project. Works well within teams.
clear
echo "Adding an assortment of plugins..."
./script/plugin install http://svn.techno-weenie.net/projects/plugins/restful_authentication/
./script/plugin install http://svn.techno-weenie.net/projects/plugins/acts_as_versioned/
./script/plugin install http://svn.techno-weenie.net/projects/plugins/acts_as_paranoid/
./script/plugin install http://svn.techno-weenie.net/projects/plugins/acts_as_attachment/
............
This is where a lot of time can be taken up: installing plugins. Nothing fancy here, just some plugins being installed.
RaPT, being worked on by Geoffrey Grosenbach, has the nice addition of plugin packs, thanks to Luke Redpath, which would be a nice replacement here in the script. In the future, I’ll be changing the installation of plugins over to a RaPT plugin pack so that it is generic enough to install whatever plugins you have in your own pack.
There is one last snippet of code, but it is just letting you know your edge Rails application has been made and sends you off with a ‘Happy Programming!’.
You can download this script off my website, here as set_rails.zip
Happy Programming!
Robert Evans
发表评论
-
Destroying a Postgres DB on Heroku
2013-04-24 10:58 890heroku pg:reset DATABASE -
VIM ctags setup ack
2012-04-17 22:13 3215reference ctags --extra=+f --e ... -
alias_method_chain方法在3.1以后的替代使用方式
2012-02-04 02:14 3240alias_method_chain() 是rails里的一个 ... -
一些快速解决的问题
2012-01-19 12:35 1435问题如下: 引用Could not open library ... -
API service 安全问题
2011-12-04 08:47 1342这是一个长期关注的课题 rest api Service的 ... -
Module方法调用好不好
2011-11-20 01:58 1300以前说,用module给class加singleton方法,和 ... -
一个ajax和rails交互的例子
2011-11-19 01:53 1859首先,这里用了一个,query信息解析的包,如下 https: ... -
Rails 返回hash给javascript
2011-11-19 01:43 2238这是一个特别的,不太正统的需求, 因为,大部分时候,ajax的 ... -
关于Rubymine
2011-11-18 23:21 2229开个帖子收集有关使用上的问题 前一段时间,看到半价就买了。想 ... -
ruby中和javascript中,动态方法的创建
2011-11-18 21:01 1192class Klass def hello(*args) ... -
textmate快捷键 汇总
2011-11-16 07:20 8091TextMate 列编辑模式 按住 Alt 键,用鼠标选择要 ... -
Ruby面试系列六,面试继续面试
2011-11-15 05:55 1980刚才受到打击了,充分报漏了自己基础不扎实,不肯向虎炮等兄弟学习 ... -
说说sharding
2011-11-13 00:53 1435这个东西一面试就有人 ... -
rails面试碎碎念
2011-11-12 23:51 1899面试继续面试 又有问ru ... -
最通常的git push reject 和non-fast forward是因为
2011-11-12 23:29 17148git push To git@github.com:use ... -
Rails 自身的many to many关系 self has_many
2011-11-12 01:43 2679简单点的 #注意外键在person上people: id ... -
Rails 3下的 in place editor edit in place
2011-11-12 01:20 913第一个版本 http://code.google.com/p ... -
Heroku 的诡异问题集合
2011-11-11 07:22 1657开个Post记录,在用heroku过程中的一些诡异问题和要注意 ... -
SCSS 和 SASS 和 HAML 和CoffeeScript
2011-11-07 07:52 12901Asset Pipeline 提供了内建 ... -
Invalid gemspec because of the date format in specification
2011-11-07 02:14 2072又是这个date format的错误。 上次出错忘了,记录下 ...
相关推荐
rails_apps_composer, 一个 gem,为 Rails 启动应用程序创建 Rails 应用程序模板 Rails 应用编辑器 Rails 应用程序编辑器 gem 安装一个 命令行 工具来从"食谱"的Collection 组装 Rails 应用程序。"你可以使用 rails_...
Rails::API 移除了 ActionView 和其他一些渲染功能,不关心Web前端的开发者可更容易、快速地开发应用程序,因此运行速度比正常的 Rails 应用程序要快。 Rails::API 可以用来创建只提供API服务(API-Only)的 Rails ...
Rails应用程序的服务器时间标头
[Ruby_on_Rails][中文][Rails_5.x]__03-2_._安裝不同版本的Rails與產生Rails_5.x版
一个Rails应用程序,为DIY小型内容分发网络CDN提供支持
chef-rails, 厨房设置一个可以与 Nginx 和 Rails 一起滚动的Ubuntu服务器 主厨 rails安装一个准备为 Ruby on Rails 栈准备的Ubuntu服务器:NginxPostgreSQLRedisMemcached带RVM的rubyPhusion乘客独立要求Ubuntu ...
本资源是在Rails开发先行的时候确定可以运行的Rails工程,可以直接用此代码运行画面
这个教程一开始会简短的介绍REST的背景和概念,接着介绍为什么要开发 REST风格的Rails应用. 使用 scaffolding,这是可以帮助我们产生 controller 和 model 细节的工具,对我们的进行REST应用的开发很有帮助.REST的...
使用Aptana+Rails开发Rails Web应用 有Aptana的安装配置等等,中文
Acts As Tennant:通过一个共享数据库的策略来为一个Rails应用添加多租户支持
这是一个在Rails应用程序中使用React并使用webpack的示例
attache-rails, 将你的Rails 应用程序与attache服务器集成 attache 使用 attache/api 在 attache服务器上集成 Rails/ActiveRecord 集成。依赖项响应,jQuery,Bootstrap 3安装注意:如果你正从V2升级,请参阅升级...
《Web开发敏捷之道:应用Rails进行敏捷Web开发(第3版)》:Ruby on Rails是一个全套的MVC web框架,它能帮你开发高质量又美观的web应用,而且开发速度快得出乎你想象。你只须集中精力于应用程序本身,Rails就会帮你...
项目的地址在https://github.com /tenderlove/phuby,尽管项目主持人Aaron发布了几个视频去证明phuby能让php在Rails下运行,但实际上在Rails社区 中,估计phuby也只是一个实验品而已。 标签:Phuby
webpack-rails, 将 web pack与你的Ruby on Rails 应用程序集成 不再维护webpack-rails 不再被维护。 有关详细信息,请参阅 #90. web pack-railsweb pack 为你提供了将 web pack集成到现有的Ruby on Rails 应用程序中...
GoOnRails: 一个Rails生成器用于生成Go代码并集成Go APIs至一个Rails app中
一个简单的 rc.d 脚本,用于在 FreeBSD 上使用和运行多个应用程序。 #特征 以非特权系统用户身份运行 rails 应用程序 使用一个 rc.d 脚本运行多个 rails 应用程序 rails 应用程序使用bundle exec unicorn运行 #...
自从发布第一个版本以来,Rails已经从一个默默无闻的玩具蜕变成了一种世界性的现象。它拿下了一个又一个的奖项,更重要的是,很多web2.0应用都选择它作为基础框架。Rails已经不再只是一小撮黑客推崇的时髦玩艺:很多...
rails_layout, 为各种前端框架生成 Rails 应用程序布局文件 RailsLayout gem使用这里 gem 可以设置你选择的前端框架的布局文件:Zurb基础 5.3Bootstrap 4.0Bootstrap 3.3它还将为 Bootstrap 或者基础设置设计视图。...