i have these classes:
class product attr_accessible :name, ... has_many :images end class image attr_accessible :image, :position, :product_id, :title belongs_to :product end
action:
def list render :json => {:result => "ok", :records => product.all} end
how can include own images every product nested attribute , not enumerate attributes in product?
you can use to_json(:include => :attr)
def list render :json => {:result => "ok", :records => product.all}.to_json(:include => :images) end
Comments
Post a Comment