Notes posted by pekkaj
RSS feed
1 thank
Including instance methods to JSON output
Use :methods parameter to include ActiveRecord instance methods to JSON output. :only and :except uses DB columns only.
@events.to_json(:include => { :images => { :only => [], :methods => [:public_url] }})
In the previous example events have multiple images and only public_url instance method is included in the JSON output.