Now, I have introduced Friendly ID without slug column
I don't know exactly what you mean here, but simply, it's like trying to start a car without the key
FriendlyID
The way FriendlyID works is to use a slug
(or other identifier) column to both create the slugged URL, and find based off the slugged ID:
extend FriendlyId
friendly_id :name, use: [:slugged, :finders]
This allows the gem to find based off either the id
or the slug
attribute
If you miss out the slug
column, this will prevent this from working, causing your error. The ways to fix this are:
- Use the slug column
- Create a slug attribute using
attr_accessor
If you'd like to try the second option, you could try this:
#app/models/ModelName.rb
attr_accessor :slug