Rails order based on association

I have a Problem and a Solution model. Problem has many solutions and Solution belongs to problem.

I need to get the recently solved problem, that means, get the last X solutions and get it's problem. I'm pretty sure there's a way to do this with named_scopes but I can't figure it out.

Any help is really appreciated :-)


Nicolás Hock I.


I actually got the named_scope working:

named_scope :solved_recently, :joins => :solutions, :order => "solutions.created_at DESC"
# Problem.solved_recently

Thanks anyway @Jacob :)

Need Your Help

Error when trying to record Audio with OpenSL ES

android android-ndk

I get an error when I run my application which utilizes the OpenSL ES API for Android. When I run the application, I get the following error:

If, else if loop broken

jquery if-statement

I've just written a small if, else if loop and I get a, unexpected token ';' error in the console. If I remove the ; after each $(this).css('top', top-3"em"); statement, I get another error saying ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.