Domanda

Is there a way to disable friendly ID in development mode?

Thank's!

È stato utile?

Soluzione

You can check rails environment in model.

class User < ActiveRecord::Base

  unless Rails.env.development?
    extend FriendlyId
    friendly_id :name, use: :slugged
  end

end

to skip generating new slug in development

class User < ActiveRecord::Base

  extend FriendlyId
  friendly_id :name, use: :slugged

  def should_generate_new_friendly_id?
    false if Rails.env.development?
  end

end

Altri suggerimenti

Try to remove this from your Gemfile:

gem 'friendly_id'

and add this on your Gemfile:

group :production, :test do
gem 'friendly_id'
end
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top