A website template with lots of features, built with ruby on rails.

friendly_id.rb 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # FriendlyId Global Configuration
  2. #
  3. # Use this to set up shared configuration options for your entire application.
  4. # Any of the configuration options shown here can also be applied to single
  5. # models by passing arguments to the `friendly_id` class method or defining
  6. # methods in your model.
  7. #
  8. # To learn more, check out the guide:
  9. #
  10. # http://norman.github.io/friendly_id/file.Guide.html
  11. FriendlyId.defaults do |config|
  12. # ## Reserved Words
  13. #
  14. # Some words could conflict with Rails's routes when used as slugs, or are
  15. # undesirable to allow as slugs. Edit this list as needed for your app.
  16. config.use :reserved
  17. config.reserved_words = %w(new edit index session login logout users admin
  18. stylesheets assets javascripts images)
  19. # ## Friendly Finders
  20. #
  21. # Uncomment this to use friendly finders in all models. By default, if
  22. # you wish to find a record by its friendly id, you must do:
  23. #
  24. # MyModel.friendly.find('foo')
  25. #
  26. # If you uncomment this, you can do:
  27. #
  28. # MyModel.find('foo')
  29. #
  30. # This is significantly more convenient but may not be appropriate for
  31. # all applications, so you must explicity opt-in to this behavior. You can
  32. # always also configure it on a per-model basis if you prefer.
  33. #
  34. # Something else to consider is that using the :finders addon boosts
  35. # performance because it will avoid Rails-internal code that makes runtime
  36. # calls to `Module.extend`.
  37. #
  38. # config.use :finders
  39. #
  40. # ## Slugs
  41. #
  42. # Most applications will use the :slugged module everywhere. If you wish
  43. # to do so, uncomment the following line.
  44. #
  45. # config.use :slugged
  46. #
  47. # By default, FriendlyId's :slugged addon expects the slug column to be named
  48. # 'slug', but you can change it if you wish.
  49. #
  50. # config.slug_column = 'slug'
  51. #
  52. # When FriendlyId can not generate a unique ID from your base method, it appends
  53. # a UUID, separated by a single dash. You can configure the character used as the
  54. # separator. If you're upgrading from FriendlyId 4, you may wish to replace this
  55. # with two dashes.
  56. #
  57. # config.sequence_separator = '-'
  58. #
  59. # ## Tips and Tricks
  60. #
  61. # ### Controlling when slugs are generated
  62. #
  63. # As of FriendlyId 5.0, new slugs are generated only when the slug field is
  64. # nil, but if you're using a column as your base method can change this
  65. # behavior by overriding the `should_generate_new_friendly_id` method that
  66. # FriendlyId adds to your model. The change below makes FriendlyId 5.0 behave
  67. # more like 4.0.
  68. #
  69. # config.use Module.new {
  70. # def should_generate_new_friendly_id?
  71. # slug.blank? || <your_column_name_here>_changed?
  72. # end
  73. # }
  74. #
  75. # FriendlyId uses Rails's `parameterize` method to generate slugs, but for
  76. # languages that don't use the Roman alphabet, that's not usually suffient. Here
  77. # we use the Babosa library to transliterate Russian Cyrillic slugs to ASCII. If
  78. # you use this, don't forget to add "babosa" to your Gemfile.
  79. #
  80. # config.use Module.new {
  81. # def normalize_friendly_id(text)
  82. # text.to_slug.normalize! :transliterations => [:russian, :latin]
  83. # end
  84. # }
  85. end