Permalink-fu 插件在 Rails 3 中不适用于我
我正在使用 Rails 3 并且下载了 permalink-fu 插件(我已经安装并使用在 Rails 2.3.8 中多次使用它,没有任何问题),但是当我转到模型的“新建”或“显示”视图(称为“列表”)时,我收到以下错误:
undefined method `evaluate_attribute_method' for #<Class:0xb57ede88>
如果我删除我的 List
模型中的 has_permalink :title
行,但我需要它才能使插件正常工作。
我的模型看起来像这样:
class List < ActiveRecord::Base
has_permalink :title
def to_param
permalink
end
end
我的控制器看起来像这样:
def show
@list = List.find_by_title(params[:permalink])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @list }
end
end
# GET /lists/new
# GET /lists/new.xml
def new
@list = List.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @list }
end
end
我的路线文件看起来像这样:
match '/:permalink' => 'lists#show', :as => :list
有人能告诉我出了什么问题吗?
I'm using Rails 3 and I've downloaded the permalink-fu plugin (I've installed and used it in Rails 2.3.8 several times without any issues), but when I go either to the New or Show view of my model (it's called List), I get the following error:
undefined method `evaluate_attribute_method' for #<Class:0xb57ede88>
This doesn't happen if I remove the has_permalink :title
line from my List
model, but I need it in order for the plugin to work.
My model looks like this:
class List < ActiveRecord::Base
has_permalink :title
def to_param
permalink
end
end
My controller looks like this:
def show
@list = List.find_by_title(params[:permalink])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @list }
end
end
# GET /lists/new
# GET /lists/new.xml
def new
@list = List.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @list }
end
end
My routes file looks like this:
match '/:permalink' => 'lists#show', :as => :list
Could anybody tell me what's wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通过安装 permalink_fu gem 而不是插件来完成这项工作。
I've made this work by installing the permalink_fu gem instead of the plugin.
放入你的 gemfile 中
然后
Put into into your gemfile
then