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

ordering items #230

Open
tommiller1 opened this issue Jun 7, 2015 · 5 comments
Open

ordering items #230

tommiller1 opened this issue Jun 7, 2015 · 5 comments

Comments

@tommiller1
Copy link

Hey,

First of all great work on this gem!

I seem to have run into an issue though, my model returns objects in desc order with this:
default_scope -> { order(created_at: :desc) }

The objects returned by entangle in the index method only take this into account on the first fetch. Subsequent fetches append the new objects at the end, is there any way to prepend new objects to the list?

Regards.

@tommiller1
Copy link
Author

Nvm issue lies with the angular plugin.

@dchacke
Copy link
Owner

dchacke commented Jun 13, 2015

@tommiller1 Thanks for reporting this! I am aware of this bug. It's because Entangled currently doesn't support scopes. In the future, the following collections should work:

Model.where(foo: 'bar')
Model.order(created_at: :desc)
Model.first(20)
# etc

At the moment, Entangled only understands .all and .find.

@dchacke
Copy link
Owner

dchacke commented Jun 13, 2015

@tommiller1 Also, what NVM issue are you experiencing?

@tommiller1
Copy link
Author

Nvm = Nevermind

It seems to work like its supposed to, the first stream contains the models in whichever order I have chosen with default_scope, subsequent notifications are sent one at a time so no ordering needed there. My problem lied with the angular plugin, it was push'ing newly created models into the 'this.resources.all' array hence the ordering problem. I made some changes to it so I can handle the create/update/destroy actions myself instead of letting the plugin do it all.

@dchacke
Copy link
Owner

dchacke commented Jun 13, 2015

Oh, got it. Yes, the scopes will also have to be understood in the front end instead of just adding to the collection. I'll leave this issue open to mark this todo as pending.

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

No branches or pull requests

2 participants