1
我在Windows XP上,护栏3.1 我用mysql2 0.2.6 但是当我 当我试图提出一个要求,如:mysql2 rails3.1错误
Product.all
我得到这个性反应:
irb(main):001:0> Product.all
←[1m←[36m (0.0ms)←[0m ←[1mSHOW TABLES←[0m
←[1m←[35m (0.0ms)←[0m describe `products`
ArgumentError: wrong number of arguments (3 for 2)
from D:/projects/rails/_API/rake/ruby/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/active_record/connection_adapters/mysql2_adapter.rb:634:in `select'
from D:/projects/rails/_API/rake/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all'
from D:/projects/rails/_API/rake/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
from D:/projects/rails/_API/rake/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/base.rb:470:in `find_by_sql'
from D:/projects/rails/_API/rake/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/relation.rb:111:in `to_a'
from D:/projects/rails/_API/rake/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/relation/finder_methods.rb:155:in `all'
from D:in `all'
from (irb):1
from D:/projects/rails/_API/rake/ruby/1.9.1/gems/railties-3.1.0/lib/rails/commands/console.rb:45:in `start'
from D:/projects/rails/_API/rake/ruby/1.9.1/gems/railties-3.1.0/lib/rails/commands/console.rb:8:in `start'
from D:/projects/rails/_API/rake/ruby/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
我的控制器:
def index
@products = Product.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @products }
end
end
我的模型:
class Product < ActiveRecord::Base
define_index do
indexes brand
indexes name
indexes denomination
end
end
您的控制器代码没有用,迁移可能更有趣,您是否也尝试重置您的数据库? '$ rake db:reset',也是imho,不错的选择窗口 – ecoologic
没有其他的我不认为迁移可以在这里帮助...我会尝试不同的宝石组合 – ecoologic