Navjeet,
Did you ever find a solution to this problem?
I have encountered the same issue and was wondering what steps you took
to solve it if any.
Thanks,
Steve
Navjeet Chabbewal wrote:> I am having this problem with pagination query in my controller class.
> I am using SQL server and following code to create pagination fails,
> complains about column name ''program_name'' (which is
valid
> column/attribute of program)
>
> The error message is:
>
> DBI::DatabaseError: S0022 (207) [Microsoft][ODBC SQL Server
> Driver][SQL Server]Invalid column name ''program_name''.:
SELECT * FROM
> (SELECT TOP 3 * FROM (......rest of query deleted......
>
>
> query_term = ''%tiger%''
> @program_pages, @programs = paginate :programs, :conditions =>
> ["program_name like ?", query_term], :per_page => 5, :include
=>
> [:status], :order => ''program_name''
>
>
> If I remove ":include => [:status]" from the paginate crestion
code,
> it works fine. So the following works:
>
> @program_pages, @programs = paginate :programs, :conditions =>
> ["program_name like ?", query_term], :per_page => 5, :order
=>
> ''program_name''
>
>
> I have to include status Active Record class because :order clause is
> dynamic and may be by status name which in status model (program model
> belongs_to status)
>
> The :include works fine on Program.find(...) in console as below:
>
>>> p = Program.find(:all, :include => [:status], :order =>
> ''program_name'' ).each { |prog| puts prog.status_code,
> prog.status.Status}
>
> Is this a sql server issue or I am not doing something correctly.
>
>
>
> --Jeet
--
Posted via http://www.ruby-forum.com/.