设置friendly_id宝石之后,我遇到了activeadmin宝石的问题,
每当我尝试使用管理面板更新,删除或创建帖子时,它都会抛出RecordNotFound
。
以下是来自 app / controllers / post_controller.rb 的代码:
class PostsController < ApplicationController
def index
@posts = Post.all
end
def show
@post = Post.friendly.find(params[:id])
end
end
来自app / models / post.rb:
class Post < ActiveRecord::Base
belongs_to :category
attr_accessible :title, :slug, :blurb, :content, :category_id
scope :tarot, -> { where(category_id: 1) }
extend FriendlyId
friendly_id :title, use: :slugged
end
答案 0 :(得分:1)
当下是app / models / post.rb:
friendly_id :title, use: :slugged
应该是:
friendly_id :title, use: :[slugged, :finders]