Reputation: 73
After setting up the friendly_id gem, I've faced a problem with the activeadmin gem,
whereby it throws RecordNotFound
whenever I'm trying to update, delete or create Posts using admin panel.
Here is the code from app/controllers/post_controller.rb:
class PostsController < ApplicationController
def index
@posts = Post.all
end
def show
@post = Post.friendly.find(params[:id])
end
end
And from 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
Upvotes: 1
Views: 404
Reputation: 73
The moment was in the app/models/post.rb:
friendly_id :title, use: :slugged
which should be:
friendly_id :title, use: :[slugged, :finders]
Upvotes: 1