rabl
rabl copied to clipboard
Extended template @object is nil
Been pulling my hair out for a few hours but I bet there's a simple solution for this. I'm trying to re-use the 'show' template in my 'search' template.
search.rabl
collection @retailers
extends 'api/v2/retailers/show'
show.rabl
object @retailer
attributes :id, :slug
child :stock_location => :location do
attributes :address1, :address2, :city, :state, :country
child @retailer.profile => :point do
attributes :lat => :latitude
attributes :long => :longitude
end
end
Here's the error that I get:
Rendered api/v2/retailers/search.rabl (2.7ms)
undefined method `profile' for nil:NilClass
/local/path/to/rails-app/app/views/api/v2/retailers/show.rabl:8:in `block in render'
Also don't ask me why these two data-points exist in separate classes/tables.
Please replace @retailer with locals[:object]. Or you can "puts locals" in the show.rabl for fun.