small medium large xlarge

21 Apr 2013, 10:38
Louis Rhys (22 posts)

I assume the method paginate for in @orders = Order.paginate page: params[:page], order: ‘created_at desc’, per_page: 10@ is from the will_paginate gem that we added in this iteration. But what I don’t understand, Order is an ActiveRecord::Base sublcass, how can an external gem add a new method definition to it?

Similar to this erb, @<p><%= will_paginate @orders %></p>@ Does it mean that @will_paginate@ method is added to the controller clase?

23 Apr 2013, 19:44
Sam Ruby (609 posts)

Unlike C#, in Ruby, classes are not immutable. You can add, modify, and remove methods on the fly.

Jump ahead to “Rails Plugins” chapter, or simply google for “Ruby Open Classes”.

You must be logged in to comment