I am rendering one record with with association like below
render :json => Scheme.where("id=?", params[:id]).first
.to_json(:include => { :navs => { :only => [:schemeCode,:navDate,:navValue] }})
Associations
Scheme has_many navs
Nav belongs_to scheme
I need to render only last record in Nav , but above will print all the navs since its one to many. I tried :limit => 1 and ordering it in desc , buts limit itself not working.Any help will be appreciated.
render :json => Scheme.where("id=?", params[:id]).first
.to_json(:include => { :navs => { :only => [:schemeCode,:navDate,:navValue], :limit => 1 }})