Ruby on Rails/will_paginate: Ordering by custom columns -


I have a complex complex SQL query whose result must be endorsed and displayed on the user. I do not want to go into the details here, but to make it simple I just select all the columns of a model, and an additional column , which is used only for serial purposes. Note. Selection (['Notes. *', '& Lt; rather complex section & gt; AS' x '"]) .Jom (...) ...

some and .group () , I finally call .order () and on the Paginate relationship If I order through the natural column of any model then everything is fine, if I order by the "artificial" column x , then rail gives me an error:

  not such column: x   

It seems because will_paginate gets actual data The first one seems to be a COUNT (*) -tatment, to process the data just to get the amount of data from the original statement. COUNT (*) -statement ( I.e.), which contains ORDER BY x . The problem is now, that will_paginate by order in statement but simply COUNT (*) And thus column can not be found / replace column definitions with x .

rail3 and will_paginate 3.0.pre2 Use.

Is there any way to get around this?

You can disable initial count queries by entering the value manually: / P>

  total_entries = Note.sect (...). Joins (...) Counting note Selection (...) .joins (...) group () .paginate (: total_entries => total_entries)   

is not a literal code sample and you have your own To get the right result, you may have to make your count query changes. This should allow you to ask complex questions when you score a page.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

memcached - Django cache performance -