Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/appcelerator/active_record_extension.rb
Instance Method Summary collapse
-
#to_json(*a) ⇒ Object
Converts the ActiveRecord object to a JSON string.
Instance Method Details
#to_json(*a) ⇒ Object
Converts the ActiveRecord object to a JSON string. Only columns with simple types are included in this object so no recursion problems can occur.
4 5 6 7 8 9 10 |
# File 'lib/appcelerator/active_record_extension.rb', line 4 def to_json(*a) result = Hash.new self.class.columns.each do |column| result[column.name.to_sym] = self.send(column.name) end result.to_json(*a) end |