Relation/Sort not working in rails controller?

Posted by Elliot on Stack Overflow See other posts from Stack Overflow or by Elliot
Published on 2010-05-19T03:10:21Z Indexed on 2010/05/19 3:30 UTC
Read the original article Hit count: 248

Filed under:

I have the following relation in my rails app:

genre - has many - authors

authors - belong to genre and has many books

books - belongs to authors and belongs to users

(users can add books to the db)

in my controller I have:

@books=current_user.books(:include => [:author => :genre], :order => 'created_at DESC')

While I am able to use the @books variable in my views - nothing is done correctly (i.e. its not showing me only books added by that user, and its not descending by created_at)...

any ideas?

--

Also I'm using clearance for the user auth, so current_user without the @ in the controller seems to work fine

Actually, I think the relation is working, only the sort might not be working...

© Stack Overflow or respective owner

Related posts about ruby-on-rails