samedi 11 novembre 2017

undefined method `find_by_friendly_id' with FriendlyId gem and Rails 5.1

I want to prevent selecting user with his id and that's why I am using this method which should work in this way, but instead I am getting this error:

undefined method `find_by_friendly_id' ...

This is the user model:

include FriendlyId
friendly_id :name, :use => [:slugged, :finders]

and the controller:

def show
    @user= User.find_by_friendly_id(params[:slug])
end

I am using latest version of the gem - 5.1.0.

Aucun commentaire:

Enregistrer un commentaire