rails demo_rest-in-place && cd demo_rest-in-placeruby script/plugin install git://github.com/janv/rest_in_place.gitwget -O public/javascripts/jquery-1.2.6.min.js http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.jsruby script/generate scaffold user name:stringvim app/views/layouts/users.html.erb# 在users.html.erb增加下面所有代码 <title>Users: <%= controller.action_name %></title> <%= stylesheet_link_tag 'scaffold' %> <%= javascript_include_tag "jquery-1.2.6.min" , "jquery.rest_in_place" %> <script type="text/javascript"> rails_authenticity_token = '<%= form_authenticity_token %>' </script>vim app/controllers/users_controller.rb# 在users_controller.rb增加一行代码 def show @user = User.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @user } format.js { render :json => @user } end endvim app/views/users/show.html.erb# 在show.html.erb增加下面所有代码 <div id="<%= dom_id @user %>"> ID: <%= @user.id %><br /> Name: <span class="rest_in_place" attribute="name"><%= @user.name %></span> </div>rake db:drop && rake db:migrate && rake db:fixtures:loadruby script/serveropen http://localhost:3000/users/<show_id>
【实 × 新 × 奇】http://www.lycom.de/ 最新报道Ruby语言、Rails框架、Ubuntu、MacOSX和软件技术信息
订阅 full-text RSS 或者 comments RSS.
Interesting links can be found at del.icio.us or by subscribing to my del.icio.us feed
Powered by SimpleLog