ccocchi / rabl-rails

Rails 4.2+ templating system with JSON, XML and Plist support.
MIT License
208 stars 51 forks source link

undefined method for nil:NilClass on Rails 5.0.1 #87

Closed razvanmitre closed 7 years ago

razvanmitre commented 7 years ago

Hello,

I am trying to switch over from rabl, but I receive this error on all templates. On rabl it works fine.

Take this template for example, it just returns some ids.

collection @properties
attributes :id

I am also using oj gem on Rails 5.0.1.

Do I need to do anything else?

Thanks

BatuhanW commented 7 years ago

@razvanmitre I think you should make collection :@properties, with symbol.

jr180180 commented 7 years ago

First off, thank you @razvanmitre for mentioning this. And, second, thanks a ton @MrWilhelm for mentioning the colon there to make it a symbol. I kept running into this issue with the following and you've saved me a TON of time.

Here's what I had:

object @example
attributes :id

adding that colon fixed it.

object :@example
attributes :id

BOOM! Thanks guys!