Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Friendly ID and Rails Engines

I followed the steps to get friendly_id working in the rails engine - which are posted here on github and it seems that when I do the following:

  s.add_dependency 'friendly_id', '~> 5.0.0'

in the engine.gemspec file and then do:

bundle install #=> works
rails g friendly_id #=> works
rake db:migrate

I get:

rake aborted!
uninitialized constant FriendlyId

Um .... What?

Update - Modal with FriendlyId

  module Xaaron
     class Role < ActiveRecord::Base
        extend FriendlyId
        friendly_id :role, use: :slugged

        validates :role, presence: true
        validates_uniqueness_of :role
      end
   end
like image 636
user3379926 Avatar asked Apr 09 '14 01:04

user3379926


1 Answers

You may need to explicitly require FriendlyId from your engine (docs):

require 'friendly_id'
like image 53
Luke Avatar answered Sep 28 '22 07:09

Luke