ruby on rails 代码技巧

git仓库输出
git archive --format=tar --prefix=actasfavor/ HEAD | (cd /home/holin/work/ && tar xf -)
输出到/home/holin/work/actasfavor/目录下

Posted by holin At May 16, 2008 16:42
加载plugins中的controller和model

# Include hook code here
require 'act_as_favor'
# make plugin controller, model, helper available to app
config.load_paths += %W(#{ActAsFavor::PLUGIN_CONTROLLER_PATH} #{ActAsFavor::PLUGIN_HELPER_PATH} #{ActAsFavor::PLUGIN_MODELS_PATH})
Rails::Initializer.run(:set_load_path, config)
# require the controller
require 'favors_controller'
# require models
require 'favor'

Posted by holin At May 15, 2008 15:36
使用最频繁的前5个命令
history | awk {'print $2'} | sort | uniq -c | sort -k1 -rn| head -n5

Posted by holin At May 15, 2008 10:40
按数组元素的某属性排序
@users.sort!{|a, b| a.last <=> b.last }

Posted by holin At May 11, 2008 14:35
按日期备份数据库
mysqldump db_name -uroot > "/root/db_backup/kaoshi_web_`date +"%Y-%m-%d"`.sql"

Posted by holin At May 08, 2008 12:05
用memcached手动cache数据

sql = "SELECT * FROM blogs LIMIT 100"
Blog.class
k = MD5.new(sql)
@blogs = Cache.get k
if @blogs.blank?
@blogs = Blog.find_by_sql(sql)
Cache.put k, @blogs, 60*30 #expire after 30min
end
memcache-client 1.5.0:
get(key, expiry = 0)
put(key, value, expiry = 0)

Posted by devon At May 04, 2008 20:39
shuffle an array

class Array
def shuffle
sort_by { rand }
end
def shuffle!
self.replace shuffle
end
end

Posted by holin At May 04, 2008 15:39
让所有的ajax请求都不render :layout

def render(*args)
args.first[:layout] = false if request.xhr? and args.first[:layout].nil?
super
end

Posted by devon At May 03, 2008 10:53
Find with Hash

Event.find(
:all,
:conditions => [ "title like :search or description like :search",
{:search => "%Tiki%"}]
)

Posted by devon At May 03, 2008 10:49
执行sql语句脚本

mysql -uroot -p123<<END
use dbame;
delete from results;
delete from examings;
quit
END

Posted by holin At May 01, 2008 12:14
SQL Transaction in Rails

def fetch_value
sql = ActiveRecord::Base.connection();
sql.execute "SET autocommit=0";
sql.begin_db_transaction
id, value =
sql.execute("SELECT id, value FROM sometable WHERE used=0 LIMIT 1 FOR UPDATE").fetch_row;
sql.update "UPDATE sometable SET used=1 WHERE id=#{id}";
sql.commit_db_transaction
value;
end

Posted by holin At April 30, 2008 09:37
显示 Flash 消息的动态效果

<% if flash[:warning] or flash[:notice] %>
<div id="notice" <% if flash[:warning] %>class="warning"<% end %>>
<%= flash[:warning] || flash[:notice] %>
</div>
<script type="text/javascript">
setTimeout("new Effect.Fade('notice');", 15000)
</script>
<% end %>
15000 毫秒后自动 notice Div 自动消失。

Posted by devon At April 29, 2008 13:02
删除环境中的常量

Object.send(:remove_const, :A)
>> Math
=> Math
>> Object.send(:remove_const, :Math)
=> Math
>> Math
NameError: uninitialized constant Math

Posted by devon At April 28, 2008 18:24
手动加上 authenticity_token
<div style="margin:0;padding:0"><input name="authenticity_token" type="hidden" value="<%= form_authenticity_token %>" /></div>

Posted by devon At April 28, 2008 14:24
Rails group_by

<% @articles.group_by(&:day).each do |day, articles| %>
<div id='day' style="padding: 10px 0;">
<h2><%= day.to_date.strftime('%y年%m月%d日') %></h2>
<%= render :partial => 'article', :collection => articles %>
</div>
<% end %>
articles 按天数分组

Posted by devon At April 25, 2008 22:32
读写文件

# Open and read from a text file
# Note that since a block is given, file will
# automatically be closed when the block terminates
File.open('p014constructs.rb', 'r') do |f1|
while line = f1.gets
puts line
end
end
# Create a new file and write to it
File.open('test.rb', 'w') do |f2|
# use "\n" for two lines of text
f2.puts "Created by Satish\nThank God!"
end

Posted by holin At April 17, 2008 02:10
遍历目录
Dir.glob(File.join('app/controllers', "**", "*_controller.rb")) { |filename| puts filename }

Posted by holin At April 16, 2008 15:28
字符串到 model
1
2
>> 'tag_course'.camelize.constantize.find(:first)
=> #<TagCourse id: 7, tag_id: 83, course_id: 2>
*camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)*
By default, camelize converts strings to UpperCamelCase. If the argument to camelize is set to ":lower" then camelize produces lowerCamelCase.
*constantize(camel_cased_word)*
Constantize tries to find a declared constant with the name specified in the string. It raises a NameError when the name is not in CamelCase or is not initialized.

Posted by devon At April 07, 2008 17:32
调用Proc
1
2
3
a = Proc.new { |i| puts i }
a['haha']
a.call('hehe')

Posted by holin At March 28, 2008 23:10
Rails中Host静态文件
1
2
config.action_controller.asset_host = "http://assets.example.com"
config.action_controller.asset_host = "http://assets-%d.example.com"
The Rails image_path and similar helper methods will then use that host to reference files in the public directory.
The second line will distribute asset requests across assets-0.example.com,assets-1.example.com, assets-2.example.com, and assets-3.example.com.

Posted by devon At March 26, 2008 18:18
打包gems到项目目录中

$ mkdir vendor/gems
$ cd vendor/gems
$ gem unpack hpricot
Unpacked gem: 'hpricot-0.4'
config.load_paths += Dir["#{RAILS_ROOT}/vendor/gems/**"].map do |dir|
File.directory?(lib = "#{dir}/lib") ? lib : dir
end

Posted by devon At March 26, 2008 18:12
在当前上下文中执行文件中的代码

instance_eval(File.read('param.txt'))
# such as
@father = 'Father'
instance_eval("puts @father")
#Produces:
#Father

Posted by holin At March 20, 2008 01:13
将当前文件所在目录加入require路径

$LOAD_PATH << File.expand_path(File.dirname(__FILE__))
# or
$: << File.expand_path(File.dirname(__FILE__))
# this one puts current path before the other path.
$:.unshift( File.expand_path(File.dirname(__FILE__)) )
*__ FILE __* 当前文件路径

Posted by holin At March 19, 2008 01:40
多字段模糊搜索

conditions = []
[:name, :school, :province, :city].each { |attr| conditions << Profile.send(:sanitize_sql, ["#{attr} LIKE ?", "%#{params[:q]}%"]) if params[:q] }
conditions = conditions.any? ? conditions.collect { |c| "(#{c})" }.join(' OR ') : nil
在profile表里,按name, school, province, city模糊搜索

Posted by devon At March 17, 2008 17:25
nginx 启动脚本

#! /bin/sh
# chkconfig: - 58 74
# description: nginx is the Nginx daemon.
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'sudo update-rc.d nginx defaults', or use the appropriate command on your
# distro.
#
# Author: Ryan Norbauer
# Modified: Geoffrey Grosenbach http://topfunky.com
# Modified: David Krmpotic http://davidhq.com
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/nginx.conf
DAEMON=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/nginx.conf
PIDFILE=/usr/local/nginx/logs/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
d_start() {
$DAEMON -c $CONFIGFILE || echo -en "\n already running"
}
d_stop() {
kill -QUIT `cat $PIDFILE` || echo -en "\n not running"
}
d_reload() {
kill -HUP `cat $PIDFILE` || echo -en "\n can't reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."

stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."

reload)
echo -n "Reloading $DESC configuration..."
d_reload
echo "."

restart)
echo -n "Restarting $DESC: $NAME"
d_stop
# One second might not be time enough for a daemon to stop,
# if this happens, d_start will fail (and dpkg will break if
# the package is being upgraded). Change the timeout if needed
# be, or change d_stop to have start-stop-daemon use --retry.
# Notice that using --retry slows down the shutdown process
# somewhat.
sleep 1
d_start
echo "."

*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
exit 3

esac
exit 0
将文件写入到 /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
测试是否可正确运行
sudo /etc/init.d/nginx start
设置自动启动
sudo /sbin/chkconfig --level 345 nginx on

Posted by devon At March 16, 2008 12:26
link_to_remote 取静态页面
1
2
<%= link_to_remote "update post", :update => 'post', :method => 'get', :url => '/post_1.html' %>
<div id='post'></div>
将 url 改为静态面页的地址即可。

Posted by devon At March 16, 2008 11:07
in_place_editor for rails2.0

module InPlaceMacrosHelper
# Makes an HTML element specified by the DOM ID +field_id+ become an in-place
# editor of a property.
#
# A form is automatically created and displayed when the user clicks the element,
# something like this:
# <form id="myElement-in-place-edit-form" target="specified url">
# <input name="value" text="The content of myElement"/>
# <input type="submit" value="ok"/>
# <a onclick="javascript to cancel the editing">cancel</a>
# </form>
#
# The form is serialized and sent to the server using an AJAX call, the action on
# the server should process the value and return the updated value in the body of
# the reponse. The element will automatically be updated with the changed value
# (as returned from the server).
#
# Required +options+ are:
# <tt>:url</tt>:: Specifies the url where the updated value should
# be sent after the user presses "ok".
#
# Addtional +options+ are:
# <tt>:rows</tt>:: Number of rows (more than 1 will use a TEXTAREA)
# <tt>:cols</tt>:: Number of characters the text input should span (works for both INPUT and TEXTAREA)
# <tt>:size</tt>:: Synonym for :cols when using a single line text input.
# <tt>:cancel_text</tt>:: The text on the cancel link. (default: "cancel")
# <tt>:save_text</tt>:: The text on the save link. (default: "ok")
# <tt>:loading_text</tt>:: The text to display while the data is being loaded from the server (default: "Loading...")
# <tt>:saving_text</tt>:: The text to display when submitting to the server (default: "Saving...")
# <tt>:external_control</tt>:: The id of an external control used to enter edit mode.
# <tt>:load_text_url</tt>:: URL where initial value of editor (content) is retrieved.
# <tt>:options</tt>:: Pass through options to the AJAX call (see prototype's Ajax.Updater)
# <tt>:with</tt>:: JavaScript snippet that should return what is to be sent
# in the AJAX call, +form+ is an implicit parameter
# <tt>:script</tt>:: Instructs the in-place editor to evaluate the remote JavaScript response (default: false)
# <tt>:click_to_edit_text</tt>::The text shown during mouseover the editable text (default: "Click to edit")
def in_place_editor(field_id, options = {})
function = "new Ajax.InPlaceEditor("
function << "'#{field_id}', "
function << "'#{url_for(options[:url])}'"
js_options = {}
if protect_against_forgery?
options[:with] ||= "Form.serialize(form)"
options[:with] += " + '&authenticity_token=' + encodeURIComponent('#{form_authenticity_token}')"
end
js_options['cancelText'] = %('#{options[:cancel_text]}') if options[:cancel_text]
js_options['okText'] = %('#{options[:save_text]}') if options[:save_text]
js_options['loadingText'] = %('#{options[:loading_text]}') if options[:loading_text]
js_options['savingText'] = %('#{options[:saving_text]}') if options[:saving_text]
js_options['rows'] = options[:rows] if options[:rows]
js_options['cols'] = options[:cols] if options[:cols]
js_options['size'] = options[:size] if options[:size]
js_options['externalControl'] = "'#{options[:external_control]}'" if options[:external_control]
js_options['loadTextURL'] = "'#{url_for(options[:load_text_url])}'" if options[:load_text_url]
js_options['ajaxOptions'] = options[:options] if options[:options]
# js_options['evalScripts'] = options[:script] if options[:script]
js_options['htmlResponse'] = !options[:script] if options[:script]
js_options['callback'] = "function(form) { return #{options[:with]} }" if options[:with]
js_options['clickToEditText'] = %('#{options[:click_to_edit_text]}') if options[:click_to_edit_text]
js_options['textBetweenControls'] = %('#{options[:text_between_controls]}') if options[:text_between_controls]
function << (', ' + options_for_javascript(js_options)) unless js_options.empty?
function << ')'
javascript_tag(function)
end
# Renders the value of the specified object and method with in-place editing capabilities.
def in_place_editor_field(object, method, tag_options = {}, in_place_editor_options = {})
tag = ::ActionView::Helpers::InstanceTag.new(object, method, self)
tag_options = {:tag => "span", :id => "#{object}_#{method}_#{tag.object.id}_in_place_editor", :class => "in_place_editor_field"}.merge!(tag_options)
in_place_editor_options[:url] = in_place_editor_options[:url] || url_for({ :action => "set_#{object}_#{method}", :id => tag.object.id })
tag.to_content_tag(tag_options.delete(:tag), tag_options) +
in_place_editor(tag_options[:id], in_place_editor_options)
end
end
解决在rails2.0以上版本使用in_place_editor时出现的 ActionController::InvalidAuthenticityToken 错误。

Posted by devon At March 15, 2008 16:20
capture in view

<% @greeting = capture do %>
Welcome to my shiny new web page! The date and time is
<%= Time.now %>
<% end %>
<html>
<head><title><%= @greeting %></title></head>
<body>
<b><%= @greeting %></b>
</body></html>
The capture method allows you to extract part of a template into a variable. You can then use this variable anywhere in your templates or layout.

Posted by devon At March 13, 2008 14:06
在 before_filter 中使用不同的layout
before_filter Proc.new {|controller| layout 'iframe' unless controller.request.env["HTTP_REFERER"] =~ /localhost/ }
如果不是从localhost这个站点来访问的,则使用 iframe 的 layout

Posted by devon At March 11, 2008 17:38
Rails中获取 HTTP_REFERER
request.env["HTTP_REFERER"]
可以取到的参数包括:
SERVER_NAME: localhost
PATH_INFO: /forum/forums
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/522.11 (KHTML, like Gecko) Version/3.0.2 Safari/522.12
HTTP_ACCEPT_ENCODING: gzip, deflate
SCRIPT_NAME: /
SERVER_PROTOCOL: HTTP/1.1
HTTP_HOST: localhost:3000
HTTP_CACHE_CONTROL: max-age=0
HTTP_ACCEPT_LANGUAGE: en
REMOTE_ADDR: 127.0.0.1
SERVER_SOFTWARE: Mongrel 1.1.3
REQUEST_PATH: /forum/forums
HTTP_REFERER: http://localhost:3000/
HTTP_COOKIE: _matchsession=BAh7BzoMY3NyZl9pZCIlNWJiNzg4NDUzOWQzNWFhZTQ4MGRkNTUwYzc0MDc5%250AZGYiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh%250Ac2h7AAY6CkB1c2VkewA%253D268e6091590591d959128f3b17b62ff46244a0a3; _slemail=temp%40email.com; _slhash=9dfd86431742273e3e96e06a1c20541d69f74dc9; _haha_session=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%250ASGFzaHsABjoKQHVzZWR7AA%253D%253D--96565e41694dc839bd244af40b5d5121a923c8e3
HTTP_VERSION: HTTP/1.1
REQUEST_URI: /forum/forums
SERVER_PORT: "3000"
GATEWAY_INTERFACE: CGI/1.2
HTTP_ACCEPT: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
HTTP_CONNECTION: keep-alive
REQUEST_METHOD: GET

(0)

相关推荐

  • Windows下Ruby on Rails开发环境安装配置图文教程

    本文详细介绍如何在Windows配置Ruby on Rails 开发环境,希望对ROR初学者能有帮助. 一.下载并安装Ruby Windows下安装Ruby最好选择 RubyInstaller(一键安装包). 下载地址: http://rubyforge.org/frs/?group_id=167 . 我们这里下载目前较新的rubyinstaller-1.9.3-p0.exe 一键安装包.这个安装包除了包含ruby本身,还有许多有用的扩展(比如gems)和 帮助文档. 双击安装,安装过程出现如下

  • 在Ruby on Rails中使用AJAX的教程

    如果没有听说过 Rails,那么欢迎您外星旅行归来,近几年大概只有那个地方没有听说过 Ruby on Rails 了.Rails 最吸引人的地方是能够很快地建立功能完备的应用程序并运行起来.Rails 为 Ajax 而内置集成的 Prototype.js 库可以轻松快速地创建所谓的富 Internet 应用程序. 本文将逐步引导您创建 Rails 应用程序.然后深入分析如何利用 Ajax 特性编写从服务器上读写数据的 JavaScript 代码. 从容起步 Ajax 之旅--Ajax 技术资源中

  • CentOS中配置Ruby on Rails环境

    详细安装步骤: 一.更新Python centos 中默认安装的python是2.4的版本,因为新版的rails需要提供nodejs的相关支持,需要更新python,更新文章可以直接移步到这个链接 http://www.tomtalk.net/wiki/Python 复制代码 代码如下: yum install -y bzip2*           #nodejs 0.8.5需要,请安装python前,先安装此模块.   wget http://www.python.org/ftp/pytho

  • 在阿里云 (aliyun) 服务器上搭建Ruby On Rails环境

    1.阿里云的一键安装web全环境 下载一键安装web全环境 sh.zip 压缩包 上传至服务器,解压.执行脚本,具体步骤详见这里 $ mv sh.zip /home/tmp/ & cd /home/tmp $ unzip sh.zip $ chmod -R 777 sh & cd sh # 任意选择一种方法执行脚本 # 方法一 $ ./install.sh # 方法二 $ ./install_nginx_xxx.sh $ ./install_mysql_xxx.sh 2.安装RVM与指定的

  • ruby on rails中Model的关联详解

    前言: 在学习model关联之前,首先要牢记一下几点: 1.关联关系,两端都要写好,否则会出现初学者看不懂的错误.而且对于理解代码,非常有好处. 2.model的名字是单数,controller是复数. 3.blong_to后面必须是单数,而且必须是小写.has_many后面必须是复数. 一:一对多 例如: 王妈妈有两个孩子,小明和小亮.可以说,王妈妈,有多个孩子.也可以说:小明,有一个妈妈;小王,有一个妈妈.我们一般在设计表的时候,是这样设计的: mothers表中id和name sons表中

  • win7安装ruby on rails开发环境

    前言 看到很多文章都说ruby环境在windows上是非常难搭建,会出现各种各样的怪问题,所以都推荐到linux和mac上安装开发.但是我按照教程搭了下,问题也不算太多.总过大概花费了2个半小时左右就完成了.所以大家不要被吓尿了,下面就把安装的步骤及具体的版本记录了一下供大家参考. 安装步骤: 开发机环境:我使用的开发机:win7 旗舰版 - 64位 (cpu是i5). 1 安装 rubyinstaller-2.0.0-p481.exe     1 选择安装目录:(如:D:\server\Rub

  • 攻克CakePHP(PHP中的Ruby On Rails框架)图文介绍第1/2页

    CakePHP框架首页: http://www.cakephp.org/ 下载后导入工程中,目录结构如下图(使用版本:1.1.19.6305) 搭建PHP环境,这里使用了AppServ2.5.9. 下载主页 http://www.appservnetwork.com/ MySQL中新建数据库blog,并运行如下SQL文建表. /**//* First, create our posts table: */CREATE TABLE posts (    id INT UNSIGNED AUTO_I

  • ruby on rails 代码技巧

    git仓库输出 git archive --format=tar --prefix=actasfavor/ HEAD | (cd /home/holin/work/ && tar xf -) 输出到/home/holin/work/actasfavor/目录下 Posted by holin At May 16, 2008 16:42 加载plugins中的controller和model # Include hook code here require 'act_as_favor' #

  • 几个加速Ruby on Rails的编程技巧

    Ruby 语言常以其灵活性为人所称道.正如 Dick Sites 所言,您可以 "为了编程而编程".Ruby on Rails 扩展了核心 Ruby 语言,但正是 Ruby 本身使得这种扩展成为了可能.Ruby on Rails 使用了该语言的灵活性,这样一来,无需太多样板或额外的代码就可以轻松编写高度结构化的程序:无需额外工作,就可以获得大量标准的行为.虽然这种轻松自由的行为并不总是完美的,但毕竟您可以无需太多工作就可以获得很多好的架构. 例如,Ruby on Rails 基于模型-

  • 利用RJB在Ruby on Rails中使用Java代码的教程

    开始之前 关于本教程 Ruby on Rails (Rails) 是用 Ruby 编写的一个 full-stack Web 应用程序框架,而 Ruby 是一种功能丰富的.免费的.可扩展的.可移植的.面向对象的脚本编制语言.Rails 在 Web 应用程序开发人员之间非常流行.通过它,可以快速有效地开发 Web 应用程序,并将其部署到任何 Web 容器中,例如 IBM? WebSphere? 或 Apache Tomcat. 在 Rails 和类似的 Web 应用程序开发框架出现之前,用于 Web

  • Ruby on Rails中MVC结构的数据传递解析

    如果读者已经开发过基于 Rails 的应用,但对其 MVC 间的数据传递还有诸多困惑,那么恭喜您,本文正是要总结梳理 Rails 数据传递的方法和技巧.Ruby on Rails 3(以下统称为 Rails 3)是当前的主要发布版本,本文所述及的内容和代码都基于此版本. Rails 3 简介 Ruby on Rails 是一个 Ruby 实现.采用 MVC 模式的开源 Web 应用开发框架,能够提供 Web 应用的全套解决方案.它的"习惯约定优于配置"的设计哲理,使得 Web 开发人员

  • 对优化Ruby on Rails性能的一些办法的探究

    1.导致你的 Rails 应用变慢无非以下两个原因: 在不应该将 Ruby and Rails 作为首选的地方使用 Ruby and Rails.(用 Ruby and Rails 做了不擅长做的工作) 过度的消耗内存导致需要利用大量的时间进行垃圾回收. Rails 是个令人愉快的框架,而且 Ruby 也是一个简洁而优雅的语言.但是如果它被滥用,那会相当的影响性能.有很多工作并不适合用 Ruby and Rails,你最好使用其它的工具,比如,数据库在大数据处理上优势明显,R 语言特别适合做统计

  • 深入理解Ruby on Rails中的缓存机制

    几个场景 首先,让我先来带您浏览几个 ChangingThePresent.org 中的页面吧.我将显示站点中几个需要缓存的地方.然后,再指出我们为其中每个地方所做出的选择以及为实现这些页面所使用的代码或策略.尤其会重点讨论如下内容: 全静态页面 几乎无变化的全动态的页面 动态页面片段 应用程序数据 先来看看静态页面.几乎每个站点都会有静态页面,如图 1 所示,其中还有我们的条款和条件.可以通过单击 register 然后再选择是否接受用户协议来浏览相应页面.对于 ChangingThePres

  • windows下安装ruby与rails时遇到的问题总结

    前言 最近因为工作的需要,准备安装ruby on rails,在网上搜了下,步骤都类似,但实际安装过程中却碰到很多问题. 说明下:文章是按照我尝试的过程描述的.但最终是靠 运行 railsinstaller一键式安装包才成功的(第五段),因此前面的部分大家可以看看,但不用去尝试. 下面来看看详细的介绍吧: 一.首先要安装ruby 因为在windows下安装ruby,都是推荐下载rubyinstaller安装程序. 先进入ruby官网http://www.ruby-lang.org/en/down

  • 在Ruby on Rails中使用Rails Active Resource的教程

    简介 当今的应用程序不仅需要和基于浏览器的客户端互操作,还需要和其他应用程序互操作.为实现互操作性,web 应用程序通常提供一个 web 服务 API.web 服务 API 通过一个网络(比如 Internet)提供对应用程序 的远程访问.直到最近,web 服务 API 还使用重型.复杂的基于 SOAP 的 web 服务集成,这种 web 服务,不仅没有什么优点,而且还需要很长时间才能实现.带有基于 Representational State Transfer (REST) 服务的 Rails

  • 简单对比分析Ruby on Rails 和 Laravel

    在线web应用程序开发目前有许多正流行的框架.  也有许多不同类型的框架,比如那些拥有大量插件,可以让你更加快速的迭代 (比如 Rails),或者还有其它非常简单和低级别的 (比如 Flask). web应用程序开发中两个相对而言更加流行的框架是 Ruby on Rails 和 Laravel.  它们两个都是非常成熟的项目,已经面世相当长一段时间了 .  Ruby on Rails 在2005年12月被引入,而 Laravel 则是2012年2月 . 如上所示的第一次发布的时间, Larave

随机推荐