Search code examples
rubyruby-on-rails-3virtual-attribute

@model.map(&:attributes) and virtual attributes


How can i use @model.map(&:attributes) to make it so that virtual attributes show up in when I render @model as json


Solution

  • @model.to_json(:method => ['virtual_attribute1', 'virtual_attribute2']))
    

    Didn't understand the map call either