我正在 Rails 中创建一个用户板应用程序,其中用户拥有任意数量的板并可以对板进行评分。我想在我的 rails 应用程序中安装acts_as_rated插件。由于这不能作为 gem 使用,我使用以下命令将其安装为插件:
rails plugin install svn://rubyforge.org/var/svn/acts-as-rated/trunk/acts_as_rated
此命令在供应商目录中安装所有必需的插件文件。接下来,我在Boards模型中包含以下代码
class Board < ActiveRecord::Base
acts_as_rated
end
接下来我重新启动控制台并运行以下命令
u=User.first
=> #<User id: 1, first_name: "taroon", created_at: "2012-03-26 09:18:20", updated_at: "2012-03-26 09:18:20">
b=Board.first
=> #<Board id: 1, name: "boards_1", created_at: "2012-03-26 09:19:39", updated_at: "2012-03-26 09:19:39">
b.rate 5, u
它给了我以下错误
ActiveRecord::StatementInvalid: Could not find table 'ratings'
from /home/swati/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.0.10/lib/active_record/connection_adapters/sqlite_adapter.rb:295:in `table_structure'
from /home/swati/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.0.10/lib/active_record/connection_adapters/sqlite_adapter.rb:186:in `columns'
from /home/swati/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.0.10/lib/active_record/base.rb:685:in `columns'
from /home/swati/.rvm/gems/ruby-1.9.2-p318/gems/activerecord-3.0.10/lib/active_record/base.rb:698:in `column_names'
from /home/swati/projects/test_projects/dummy_project/vendor/plugins/acts_as_rated/lib/acts_as_rated.rb:193:in `rate'
from (irb):6
from /home/swati/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.0.10/lib/rails/commands/console.rb:44:in `start'
from /home/swati/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.0.10/lib/rails/commands/console.rb:8:in `start'
from /home/swati/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.0.10/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
我检查了迁移,但没有创建评级表的迁移。我也不知道这张表中的字段。
任何人都可以请建议我解决这个问题..