Rails 3和RJS

den*_*min 5 ruby ruby-on-rails rjs ruby-on-rails-3

我使用rails 3.0.0.beta

是否有任何新的语法来编写RJS,这是一个例子

  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
Run Code Online (Sandbox Code Playgroud)

den*_*min 11

这是截屏视频http://railscasts.com/episodes/205-unobtrusive-javascript

更新2011年4月:正在为Rails 3.1提取RJS

当Rails 3.1出局时,prototype-rails将成为一个宝石

使用RJS的应用程序必须将此行添加到他们的Gemfile,同时在3.1版本之前使用Rails master:

gem 'prototype-rails', :git => 'git://github.com/rails/prototype-rails.git'
Run Code Online (Sandbox Code Playgroud)

有关ruby on rails的更多信息可以在本文中找到

github上的prototype-rails