Greetings, I''m trying to make a simple logging application that just displays the last few rows of information in the log. In order to do this, I am trying to use the ":offset" option for find. However, I am not getting the results I expect. For testing purposes, the query is being run against a table (MySQL) that contains 11 records. According to the RoR documentation, when I use the :offset parameter as shown below, I expect to get back 6 records instead of 11. Am I just not reading the documentation correctly? # This should return all rows in the table after the fifth row @transactions = Transaction.find(:all, :offset => 5 ) # Should show 6 if the total rows are 11 puts "TOTAL ROWS RETURNED IS: " + @transactions.size.to_s Thanks in advance for any insight or help. Doug -- Posted via http://www.ruby-forum.com/.
Doug Meharry wrote:> Greetings, > > I''m trying to make a simple logging application that just displays the > last few rows of information in the log. In order to do this, I am > trying to use the ":offset" option for find. However, I am not getting > the results I expect. > > For testing purposes, the query is being run against a table (MySQL) > that contains 11 records. According to the RoR documentation, when I > use the :offset parameter as shown below, I expect to get back 6 records > instead of 11. Am I just not reading the documentation correctly? > > # This should return all rows in the table after the fifth row > @transactions = Transaction.find(:all, :offset => 5 ) > > # Should show 6 if the total rows are 11 > puts "TOTAL ROWS RETURNED IS: " + @transactions.size.to_s > > Thanks in advance for any insight or help. > > DougIt appears MySQL also needs a ":limit" parameter specified in addition to the ":offset" parameter. I have not tested this issue with PostgreSQL or any other dbs but assume this could also apply in other such cases. Doug -- Posted via http://www.ruby-forum.com/.
You could use the created_at or updated_at column and do something where you show the most recent entries like this: ... ORDER BY updated_at DESC LIMIT 10 Don''t know if that works for your situation or not, but will give you similar results as what your example is trying to get. Regards, Michael -- Posted via http://www.ruby-forum.com/.
:offset it dependent on :limit, in other words, if you don''t specify :limit, :offset is basically ignored (look at the sql generated in your log to see). this is because the offset is part of the limit clause and is optional, however, the # of rows to limit is not select * from table ... [limit [offset,] rows] so select * from table ... limit 10, 20 would select limit the number of returned rows to 20 starting at row 10 hope this is clear enough for you. Chris On 8/8/06, Doug Meharry <doug@dmeharry.com> wrote:> Greetings, > > I''m trying to make a simple logging application that just displays the > last few rows of information in the log. In order to do this, I am > trying to use the ":offset" option for find. However, I am not getting > the results I expect. > > For testing purposes, the query is being run against a table (MySQL) > that contains 11 records. According to the RoR documentation, when I > use the :offset parameter as shown below, I expect to get back 6 records > instead of 11. Am I just not reading the documentation correctly? > > # This should return all rows in the table after the fifth row > @transactions = Transaction.find(:all, :offset => 5 ) > > # Should show 6 if the total rows are 11 > puts "TOTAL ROWS RETURNED IS: " + @transactions.size.to_s > > Thanks in advance for any insight or help. > > Doug > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Rob Gabaree
2006-Aug-09 13:04 UTC
[Rails] Is the First Edition of "Agile Web Development with Rails" still relevant?
Hi, I purchased the first edition of "Agile Web Development with Rails" some time back and never had a time to get into it. I want to learn now but I''ve seen there''s a second edition. Is the content in the first edition still relevant, or are some parts of it "depreceated" or no longer current? Should I get the second edition? What about "Rails Receipes" as well? Thanks, Rob
James Ludlow
2006-Aug-09 14:51 UTC
[Rails] Is the First Edition of "Agile Web Development with Rails" still relevant?
On 8/9/06, Rob Gabaree <lists@rawb.net> wrote:> I purchased the first edition of "Agile Web Development with Rails" some > time back and never had a time to get into it. I want to learn now but > I''ve seen there''s a second edition. Is the content in the first edition > still relevant, or are some parts of it "depreceated" or no longer > current? Should I get the second edition? What about "Rails Receipes" > as well?I have the 1st edition and I don''t regret buying the 2nd edition at all. It''s been well worth it, even as a beta book. Pieces of the 1st edition are deprecated, yes. -- James
Richard Conroy
2006-Aug-09 15:31 UTC
[Rails] Is the First Edition of "Agile Web Development with Rails" still relevant?
Rails Recipes is quite good too, but it is very much advanced material for people comfortable with Rails. n00bs like me can''t put much of it into practice, but theres a lot of nice stuff in there - kind of a reward at the end of the journey. On 8/9/06, James Ludlow <jamesludlow@gmail.com> wrote:> On 8/9/06, Rob Gabaree <lists@rawb.net> wrote: > > I purchased the first edition of "Agile Web Development with Rails" some > > time back and never had a time to get into it. I want to learn now but > > I''ve seen there''s a second edition. Is the content in the first edition > > still relevant, or are some parts of it "depreceated" or no longer > > current? Should I get the second edition? What about "Rails Receipes" > > as well? > > I have the 1st edition and I don''t regret buying the 2nd edition at > all. It''s been well worth it, even as a beta book. > > Pieces of the 1st edition are deprecated, yes. > > -- James > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Mathieu Chappuis
2006-Aug-09 15:31 UTC
[Rails] Is the First Edition of "Agile Web Development with Rails" still relevant?
> I purchased the first edition of "Agile Web Development with Rails" some > time back and never had a time to get into it. I want to learn now but > I''ve seen there''s a second edition. Is the content in the first edition > still relevant, or are some parts of it "depreceated" or no longer > current? Should I get the second edition?AFIK there are no statements in 1st deprecrated with Rails 1.1.4. Sure, 2nd edition have majors rewrite and additions, but you can start learning with a recent rails setup and this book. Big enhancements in 2nd are for medium level (web)developers (RJS Templates, Migrations, Polymorphic associations), your 1st edition cover unchanged basics for beginning, let''s go :) I''m using last Rails 1.1.4 with 1st, just printed some chapters from 2nd PDF (Migrations) because I want use them, and I keep an eye on the online API for new methods and minor changes.>What about "Rails Receipes" as well?Good indeep rails programming techniques, a very good complement, and more up to date with rails 1.1 than AWDWR, too few RJS for my taste.
Louis Simoneau
2006-Aug-09 15:55 UTC
[Rails] Is the First Edition of "Agile Web Development with Rails" still relevant?
Yeah, I started to teach myself Rails a week ago with the first edition book, but found that certain aspects were a little behind the kind of code I was seeing in online tutorials, etc. (especially with regards to database migration, if you watch the "migrations" screencast you''ll be scratching your head with the first ed.)...so I picked up the beta .pdf of the second edition, and am liking it much more. Just in the depot application, some things are implemented in a much cleaner way (more "Ruby-like" seems to be the parlance). On the other hand, if you can''t wait to start coding, you can use the first edition for now, just check out a tutorial on migrations: http://glu.ttono.us/articles/2005/10/27/the-joy-of-migrations and use those instead of the DDL schemas used in the book. That seems to be the most important difference with regards to the example app (other than the second ed. gives some examples of AJAX integration). As for the rest of the book, I haven''t gotten there yet :-) I would still strongly recommend getting the second edition book when it comes out (or getting the beta .pdf now.) I seem to recall that the thing is scheduled for release in September, so it''s not much of a wait. --Louis On 8/9/06, James Ludlow <jamesludlow@gmail.com> wrote:> > On 8/9/06, Rob Gabaree <lists@rawb.net> wrote: > > I purchased the first edition of "Agile Web Development with Rails" some > > time back and never had a time to get into it. I want to learn now but > > I''ve seen there''s a second edition. Is the content in the first edition > > still relevant, or are some parts of it "depreceated" or no longer > > current? Should I get the second edition? What about "Rails Receipes" > > as well? > > I have the 1st edition and I don''t regret buying the 2nd edition at > all. It''s been well worth it, even as a beta book. > > Pieces of the 1st edition are deprecated, yes. > > -- James > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060809/93ff9dd3/attachment.html
Kevin Olbrich
2006-Aug-09 17:21 UTC
[Rails] Is the First Edition of "Agile Web Development with
On Wednesday, August 09, 2006, at 5:23 PM, Mathieu Chappuis wrote:>> I purchased the first edition of "Agile Web Development with Rails" some >> time back and never had a time to get into it. I want to learn now but >> I''ve seen there''s a second edition. Is the content in the first edition >> still relevant, or are some parts of it "depreceated" or no longer >> current? Should I get the second edition? > >AFIK there are no statements in 1st deprecrated with Rails 1.1.4. > >Sure, 2nd edition have majors rewrite and additions, but you can start >learning with a recent rails setup and this book. > >Big enhancements in 2nd are for medium level (web)developers (RJS >Templates, Migrations, Polymorphic associations), your 1st edition >cover unchanged basics for beginning, let''s go :) > >I''m using last Rails 1.1.4 with 1st, just printed some chapters from >2nd PDF (Migrations) because I want use them, and I keep an eye on the >online API for new methods and minor changes. > >>What about "Rails Receipes" as well? > >Good indeep rails programming techniques, a very good complement, and >more up to date with rails 1.1 than AWDWR, too few RJS for my taste. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsA lot of the testing stuff in the 1st edition is deprecated now. Especially the stuff related to instantiated fixtures. _Kevin www.sciwerks.com -- Posted with http://DevLists.com. Sign up and save your mailbox.
Kirk R
2006-Aug-09 19:56 UTC
[Rails] Is the First Edition of "Agile Web Development with Rails" still relevant?
I found the Recipes book to be very good depending on your Ruby skillz. If you Ruby skillz needs some love David Black''s "Ruby for Rails" is really good. But I have 2nd edition of the Agile book in beta and I felt it was a worthy upgrade over the 1st edition. On 8/9/06, Richard Conroy <richard.conroy@gmail.com> wrote:> Rails Recipes is quite good too, but it is very much advanced > material for people comfortable with Rails. n00bs like me can''t > put much of it into practice, but theres a lot of nice stuff in there > - kind of a reward at the end of the journey. > > On 8/9/06, James Ludlow <jamesludlow@gmail.com> wrote: > > On 8/9/06, Rob Gabaree <lists@rawb.net> wrote: > > > I purchased the first edition of "Agile Web Development with Rails" some > > > time back and never had a time to get into it. I want to learn now but > > > I''ve seen there''s a second edition. Is the content in the first edition > > > still relevant, or are some parts of it "depreceated" or no longer > > > current? Should I get the second edition? What about "Rails Receipes" > > > as well? > > > > I have the 1st edition and I don''t regret buying the 2nd edition at > > all. It''s been well worth it, even as a beta book. > > > > Pieces of the 1st edition are deprecated, yes. > > > > -- James > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Just because you ''re not paranoid doesn''t mean they aren''t out to get you.
Dave Thomas
2006-Aug-10 02:02 UTC
[Rails] Is the First Edition of "Agile Web Development with
On Aug 9, 2006, at 13:25, Kevin Olbrich wrote:> A lot of the testing stuff in the 1st edition is deprecated now. > Especially the stuff related to instantiated fixtures.That''s the biggest problem--they made that incompatible change after the book went to press. The other stuff should work, but the new Rails adds a lot of additional features (such as migrations and RJS) they are pretty important. The first edition still works in terms of writing viable code for Rails applications... Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060810/1edebaca/attachment.html