Rails 3 和 RJS [英] Rails 3 and RJS
本文介绍了Rails 3 和 RJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 rails 3.0.0.beta
I use the rails 3.0.0.beta
有没有什么新的语法可以写RJS,举个例子
Is there any new syntax to write RJS, here is an example
def remote_create
@photo = Photo.new(params[:photo])
respond_to do |format|
if @photo.save
# add @photo's thumbnail to last import tag
format.js {
render :update do |page|
page.insert_html :bottom, 'polaroids' , :partial => 'polaroid', :locals => {:photo => @photo}
end
}
else
#...
end
end
end
推荐答案
这里是截屏视频 http://railscasts.com/episodes/205-unobtrusive-javascript
2011 年 4 月更新:正在为 Rails 3.1 提取 RJS
UPDATE April 2011: RJS is being extracted for Rails 3.1
当 Rails 3.1 发布时,prototype-rails 将成为一个瑰宝
prototype-rails is going to be a gem when Rails 3.1 is out
在 3.1 版本之前使用 RJS 的应用程序必须在其 Gemfile 中添加这一行:
Applications using RJS have to add this line to their Gemfile while working against Rails master before the 3.1 release:
gem 'prototype-rails', :git => 'git://github.com/rails/prototype-rails.git'
有关 ruby on rails 的更多信息可以在 这篇文章中找到一个>
more info on ruby on rails's could be found in this article
这篇关于Rails 3 和 RJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文