0

When I set the slug_limit on friendly_id as per the documentation in the initializer, I see the following error:

Failure/Error: extend FriendlyId

NoMethodError:
  undefined method `slug_limit=' for #<#<Class:0x00007ffe66dd01a0>:0x00007ffe66dd0150>
# ./config/initializers/friendly_id.rb:68:in `block in <top (required)>'

My model implements friendly_id like this:

extend FriendlyId
friendly_id :title, use: [:slugged, :finders]

How do I set the slug limit?

Rimian
  • 36,864
  • 16
  • 117
  • 117
  • 1
    I cant find a method "slug_limit", could you send me the doc link? – 7urkm3n Feb 04 '21 at 00:20
  • What is in `config/initializers/friendly_id.rb`? And as mentioned above, I can't see any reference to `slug_limit` in the documentation -- so what is this code expected to be doing? – Tom Lord Feb 04 '21 at 14:25
  • Ah wait, I've just seen [this](https://github.com/norman/friendly_id/blob/819c0b111b0f722809c0a13ad025c5191a278f85/lib/friendly_id/initializer.rb#L63), which you presumably uncommented in your generated initializer? Maybe this is only valid id you also specify `config.use :slugged`? Like I said, it would be helpful to see that whole configuration file, rather than me guessing what it might say. – Tom Lord Feb 04 '21 at 14:31
  • Or maybe you're using an **old version** of the gem, that does not have the [`slug_limit`](https://github.com/norman/friendly_id/pull/809) feature?? Which version of the gem are you using? – Tom Lord Feb 04 '21 at 14:34

1 Answers1

1

You could try to set slug_limit like this from the test example:

extend FriendlyId
friendly_id :title, use: :slugged, slug_limit: 40
eux
  • 3,072
  • 5
  • 14