Neigaard
Neigaard

Reputation: 4050

Parsing a JSON POST request to a object?

I am quite new to rails. I have this code in my controller:

@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

This works super, but how do I get the other way? How do I parse the received JSON to a Schedules object?

Thank you Søren

Upvotes: 1

Views: 620

Answers (1)

Hugo
Hugo

Reputation: 2913

Schedule.new.from_json(json)

Upvotes: 1

Related Questions