Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use a collection as the default object. Fixes #142 #467

Merged
merged 1 commit into from
Jun 19, 2013

Conversation

mrbrdo
Copy link
Contributor

@mrbrdo mrbrdo commented Jun 19, 2013

No description provided.

@nesquena
Copy link
Owner

Thanks for contributing. I can see how this could fix the issue you mentioned earlier if a collection happens to match the controller name

nesquena added a commit that referenced this pull request Jun 19, 2013
Do not use a collection as the default object. Fixes #142
@nesquena nesquena merged commit e61ae73 into nesquena:master Jun 19, 2013
@mrbrdo
Copy link
Contributor Author

mrbrdo commented Jun 19, 2013

@nesquena You might want to also consider coercing to array using to_a in data_name
https://github.com/nesquena/rabl/blob/master/lib/rabl/helpers.rb#L31

Current code there might be causing a similar problem in some cases, since it's calling #first, better would be to_a.first. I didn't want to change that because I can see a potential issue if you do something like

collection @stuff.limit(5)

It is necessary to consider stuff like this if calling to_a, so that it won't load all the models if the user isn't using them in the template. Might be a non-issue though, depending on where data_name is called (I did not look too much into it). Would be nice if you could look into that too.

DouweM added a commit to DouweM/rabl that referenced this pull request Oct 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants