On Thursday, May 29, 2014 1:19:11 PM UTC-7, Kenny Meyer wrote: > > I have a Post and Comments table. > > Post has many comments, and Comment belongs to a post. > > I want to have primary keys which start at 0 for a Post, so that I can > access comments in a REST-ful manner as: > > /posts/1/comments/1/posts/2/comments/1 > > How can I achieve that with Rails 3 and Sequel? > In general, primary keys are going to start at 1, not 0. Your example shows 1, but I'm not sure if that is an oversight. In any case, if you want your primary key to start at 0, you probably have to write database-specific code to do so.
Assuming you are using those routes in Rails, loading the appropriate Sequel objects can be done via: Post.with_pk!(1).comments_dataset.with_pk!(1) Post.with_pk!(2).comments_dataset.with_pk!(1) Or: Comment.where(:post_id=>1).with_pk!(1) Comment.where(:post_id=>2).with_pk!(1) Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
