2010-08-25 79 views
1

我對軌道很陌生。我在我的控制器中有這樣的代碼:解析一個JSON POST請求到一個對象?

@schedules = Schedules.find(:all, :conditions => ["id = ?", params[:id]]) 
respond_to do |format| 
    format.html # list.html.erb 
    format.json { render :json => @schedules.to_json } 
end 

這個工程超級,但我怎麼得到另一種方式?我如何解析收到的JSON到一個Schedules對象?

謝謝 瑟倫

回答

1
Schedule.new.from_json(json)