ruby - Rails - How does 'will_paginate' plugin work? -
will_paginate plugin allows whatever activerecord paginated.
indeed, paginate
method available within activerecord. example, if want paginate order
, do:
order.paginate page:params[:page], order: 'created_at desc'
how paginate
method created? will_paginate plugin kind of: "taking activerecord definition , injecting paginate
method into?
furthermore, keep example, if above assumption correct:
how avoid conflict plugin if whatever reason, order
has defined proper paginate totally different purpose?
will_paginate uses extend method add modules activerecord::base class. see https://github.com/mislav/will_paginate/blob/master/lib/will_paginate/active_record.rb#l202
if order has method called paginate override activerecord::base#paginate method.
Comments
Post a Comment