1 2 3 | class IndianHistory < ActiveResource::Base self.site = “<a href="http://indian-history.com/"><code>http://indian-history.com</code></a>” end |
1 | >> books = IndianHistory.find (:all) |
1 | >> books = IndianHistory.find(:all, :params => { :title => “Akbar”}} |
1 | >> IndianHistory.create (:title => “Jhansi Stories”, :amount => 233.00, :available => 0) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | class IndianHistoryController < ActiveResource::Base def create @book = IndianHistory.new (params [:indian_history]) respond_to do |format| if @book.save flash[:notice] = “New title added successfully” format.html { redirect_to(@book) } format.xml { render :xml => @book, :status => :created} else format.html { render :action => “new” } format.xml { render :xml => @book.errors, :status => :unprocessable_entity} end end end end |
1 2 3 4 5 | >> book= IndianHistory.find (2) >> book.available = 1 >> book.save >> book = IndianHistory.find (2) >> book.available # => 1 |
1 | >> IndianHistory.delete(2) |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |