未定义的局部变量或方法“acts_as_voteable”为了
免责声明:我是 Ruby on Rails 新手。尝试谷歌搜索和 StackOverflow 搜索但没有成功。
我正在创建我的第一个 Ruby on Rails 应用程序,并希望利用“thumbs_up”插件,该插件类似于 vote_fu 和acts_as_voteable,并且在 Rails 3 下工作。 https://github.com/brady8/thumbs_up
我已按照上面页面上的安装说明进行操作,当我运行“gem list”我看到thumbs_up插件已安装。
我尝试将“acts_as_voteable”混合添加到如下所示的模型中:
class Foo < ActiveRecord::Base
validates :title, :presence => true
validates :description, :presence => true
acts_as_voteable
end
当我尝试浏览我的应用程序时,我收到以下错误:
未定义的局部变量或方法`acts_as_voteable' for #
堆栈跟踪对我来说看起来不太有用:
活动记录 (3.0.0) lib/active_record/base.rb:1016:in
method_missing'app/models/foo.rb:7 主动支持 (3.0.0) lib/active_support/dependency.rb:454:in 加载'activesupport(3.0.0) lib/active_support/dependency.rb:454:in
const_missing'activesupport(3.0.0) lib/active_support/dependency.rb:181:inload_file' activesupport (3.0.0) lib/active_support/dependency.rb:591:in
new_constants_in' activesupport (3.0.0) lib/active_support/dependency.rb:453:inload_file' activesupport (3.0.0) lib/active_support/dependency.rb:340:in
require_or_load'activesupport (3.0.0) lib/active_support/dependency.rb:491:in load_missing_constant' activesupport (3.0.0) lib/active_support/dependency.rb:183:in每个'activesupport (3.0.0) lib/active_support/dependency.rb:181:in
const_missing'activesupport(3.0.0) lib/active_support/dependency.rb:503:in load_missing_constant' activesupport (3.0.0) lib/active_support/dependency.rb:183:in const_missing'activesupport(3.0.0) lib/active_support/dependency.rb:181:in每个'activesupport (3.0.0) lib/active_support/dependency.rb:181:in
const_missing' 应用程序/控制器/foos_controller.rb:5:in “索引”
有什么想法吗?我似乎无法在解决这个问题上取得任何进展。
谢谢你, -抢
Disclaimer: I'm a Ruby on Rails newbie. Tried Googling and searching StackOverflow without success.
I am creating my first Ruby on Rails app and would like to take advantage of the "thumbs_up" plugin which is similar to vote_fu and acts_as_voteable and works under Rails 3.
https://github.com/brady8/thumbs_up
I have followed the installation instructions on the page above and when I run "gem list" I see the thumbs_up plugin is installed.
I have attempted to add the "acts_as_voteable" mixin to a model which looks like this:
class Foo < ActiveRecord::Base
validates :title, :presence => true
validates :description, :presence => true
acts_as_voteable
end
When I try to browse my app I receive the following error:
undefined local variable or method `acts_as_voteable' for #
The stacktrace does not look very useful to me:
activerecord (3.0.0)
lib/active_record/base.rb:1016:inmethod_missing' app/models/foo.rb:7
load' activesupport (3.0.0)
activesupport (3.0.0)
lib/active_support/dependencies.rb:454:in
lib/active_support/dependencies.rb:454:inload_file' activesupport (3.0.0)
new_constants_in' activesupport
lib/active_support/dependencies.rb:591:in
(3.0.0)
lib/active_support/dependencies.rb:453:inload_file' activesupport (3.0.0)
require_or_load' activesupport
lib/active_support/dependencies.rb:340:in
(3.0.0)
lib/active_support/dependencies.rb:491:inload_missing_constant' activesupport
const_missing' activesupport (3.0.0)
(3.0.0)
lib/active_support/dependencies.rb:183:in
lib/active_support/dependencies.rb:181:ineach' activesupport (3.0.0)
const_missing' activesupport (3.0.0)
lib/active_support/dependencies.rb:181:in
lib/active_support/dependencies.rb:503:inload_missing_constant' activesupport
const_missing' activesupport (3.0.0)
(3.0.0)
lib/active_support/dependencies.rb:183:in
lib/active_support/dependencies.rb:181:ineach' activesupport (3.0.0)
const_missing'
lib/active_support/dependencies.rb:181:in
app/controllers/foos_controller.rb:5:in
`index'
Any ideas? I can't seem to make any progress on resolving this.
Thank you,
-Rob
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试添加一个初始化文件
或者您可以只从您的模型中需要它
Try adding an initializer file
Or you could just require it from your model