I’m having an error from Linux via freeTDS/ODBC to SQL Server with
cod that runs fine against SQLite and MySQL. Here’s the code:
def find_recipes_for_workorder_by_id
@recipe_pages, @recipes = paginate_with_sort :recipes, :per_page
=> 10,
:conditions => [“recipe.workorder_id = ?”, params
[:workorder]]
render :template => ‘recipe/list’
end
(I’ve included the custom sorting code at bottom of message.)
Here’s the top of the error:
DBI::DatabaseError ( (8156) [unixODBC][FreeTDS][SQL Server]The column
‘name’ was specified multiple times for ‘tally’.):
/usr/lib/site_ruby/1.8/DBD/ODBC/ODBC.rb:168:in execute' /usr/lib/site_ruby/1.8/dbi/dbi.rb:640:in
execute’
/usr/lib/site_ruby/1.8/dbi/dbi.rb:671:in select_all' /vendor/rails/activerecord/lib/active_record/connection_adapters/ sqlserver_adapter.rb:354:in
add_limit_offset!’
/vendor/rails/activerecord/lib/active_record/base.rb:931:in
add_limit!' /vendor/rails/activerecord/lib/active_record/base.rb:924:in
construct_finder_sql’
Any help appreciated!
Jamie
class ActionController::Base
def paginate_with_sort(collection_id, options={})
@params[:sort_direction] ||= ‘-1’
asc_desc = {‘1’ => “asc”, ‘-1’ => “desc”}
options[:order] = “#{@params[:sort_by]} #{asc_desc[@params
[:sort_direction]]}” if @params[:sort_by]
@params[:sort_direction] = @params[:sort_direction].to_i * (-1)
paginate collection_id, options
end
end