Ruby on Rails Monday, March 26, 2012



On Mon, Mar 26, 2012 at 3:48 PM, Erwin <yves_dufour@mac.com> wrote:
thanks for your feedback ..  maybe so mistake typing this post ,
however the url is fine , as the action is correctly reached ..
if I use :
render :text => @rate
then the result is displayed ..
so it's not an Ajax call issue , rather something I don't get right
with json

can I use  render :json  => @ rate

@rate being a String object ?  I tried
render :json => {:name => "joe"}  # i.e example
and the result is also received back

so what could be wrong withe  render :json => "<String>  ???


well I think you should change that hash {:name=>"joe"}.to_json
for example today I've done something like this

@activities = Activity.all

respond_to do |format|
  format.json { render :json => @activities.to_json(:only=>[:id])} 
end


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment