Skip to content

Support pass-thru of Mongoid field alias (:as parameter)#15

Merged
pyromaniac merged 2 commits intomongoid:masterfrom
johnnyshields:master
Oct 10, 2013
Merged

Support pass-thru of Mongoid field alias (:as parameter)#15
pyromaniac merged 2 commits intomongoid:masterfrom
johnnyshields:master

Conversation

@johnnyshields
Copy link
Copy Markdown
Member

Support pass-thru of Mongoid field alias (:as parameter) to underlying Mongoid Orderable field

Example:

orderable column: :pos, as: :position

This will store the orderable field in the DB as a minified name pos, however you can access it in Ruby as position

@pyromaniac
Copy link
Copy Markdown
Collaborator

Could you please add backward compatibility for mongoid 2?

@johnnyshields
Copy link
Copy Markdown
Member Author

@pyromaniac this uses a native feature on mongoid which is only available in v3 and greater. In mongoid two, the parameter should not be used.

@pyromaniac
Copy link
Copy Markdown
Collaborator

Yeah, I know, but according to specs, you should add a respond_to?(:database_field_name) check https://travis-ci.org/pyromaniac/mongoid_orderable/jobs/12337830 to make this work.

- Ensure specs pass on Mongoid 2
@johnnyshields
Copy link
Copy Markdown
Member Author

Done and passing. I had to make the modification to the spec itself, since actual code is backwards compatible.

pyromaniac added a commit that referenced this pull request Oct 10, 2013
Support pass-thru of Mongoid field alias (:as parameter)
@pyromaniac pyromaniac merged commit eeff8f3 into mongoid:master Oct 10, 2013
@pyromaniac
Copy link
Copy Markdown
Collaborator

Thanks, merged

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.

2 participants