I am rendering out some json like this:
render :json => r.to_json(:methods => ['food_item','drink_item'])
Both food_item and drink_item have a has_one associated price. How could I load this to be rendered in the json?
thx
edit #1 Here's some more code - wrote late last night:
class MenuItem < ActiveRecord::Base
...
#price
has_one :price, :as => :pricable
accepts_nested_attributes_for :price
end
class ObjectConnection < ActiveRecord::Base
...
def food_item
MenuItem.find(food_id)
end
def drink_item
MenuItem.find(drink_id)
end
end