getting most recent blog posts

Subscribe to getting most recent blog posts 6 post(s), 2 voice(s)

 
Avatar Lei 14 post(s)

Hi Eldon,

I’ve just rebuilt the community site. I found a problem with the Post.recent class method, which is used to grab the most recent blog posts grouped by unique users. But for some reason the method actually returns the most recently created users with their first post. The Photo.recent method seems to have the same problem. Not sure if this is a database specific problem, I’m using Mysql, haven’t tested it with sqlite.

 
Avatar EldonAlameda Administrator 216 post(s)

Hi Lei,

I was out of town for the holiday weekend but will take a look at the queries over the next day or so to see if I can determine if something was changed within ActiveRecord that might have caused this issue for you or if there’s a difference between MySQL and sqlite that might be causing it.

As an FYI – typically what I’ll do is to evaluate the pure SQL that’s generated by ActiveRecord in both databases to see if there might be a problem.

 
Avatar EldonAlameda Administrator 216 post(s)

Lei,

I haven’t been able to replicate the problem yet. But I’m going to give it another whack soon after dumping a few hundred records into the database to see if I can recreate what you’re seeing.

Which version of Rails are you using? 1.2.6 like in the book or something newer?

 
Avatar Lei 14 post(s)

Eldon,

I’m using 2.0.2. I only had around 6 users and less than 15 posts. Maybe I should try it out with Sqlite3, though it’s unlikely to be a database specific problem.

 
Avatar EldonAlameda Administrator 216 post(s)

At a meeting with a client right now, but I wouldn’t expect it to be an issue with MySQL vs Sqlite either, my big curiosity though is if there had been a change to SQL that ActiveRecord would generate for this command.

 
Avatar Lei 14 post(s)

hmm.. I’m curious too. hope you had a good meeting with your client :)