Rails: Is there a way to disable friendly ID in development mode?
-
02-07-2021 - |
Pregunta
Is there a way to disable friendly ID in development mode?
Thank's!
Solución
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
Otros consejos
Try to remove this from your Gemfile:
gem 'friendly_id'
and add this on your Gemfile:
group :production, :test do
gem 'friendly_id'
end
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow