I just wandered the difference between:
format.json { render :json => @post, :include => [ :user ] }
...and
format.json { render :json => @post.to_json(:include => [ :user ]) }
They both seem to work?
I just wandered the difference between:
format.json { render :json => @post, :include => [ :user ] }
...and
format.json { render :json => @post.to_json(:include => [ :user ]) }
They both seem to work?
it's the same. if you have a look at actionpack renderers.rb
you will see how it works:
add :json do |json, options|
json = json.to_json(options) unless json.kind_of?(String)
json = "#{options[:callback]}(#{json})" unless options[:callback].blank?
self.content_type ||= Mime::JSON
json
end
© 2022 - 2024 — McMap. All rights reserved.