maiconsanson
maiconsanson

Reputation: 249

Prohibit some words from being saved

I have the following routes output:

http://localhost:3001/chefs/peter (shows the chef profile **based on username**)
http://localhost:3001/chefs/edit (can edit their profile if logged)

How to prevent user to create a username that already has a action name like edit?

Upvotes: 1

Views: 78

Answers (1)

Alper Karapınar
Alper Karapınar

Reputation: 2694

I think there should be more than one solution but using exclusion validation should work.

validates :name, :exclusion => { :in => %w(edit show) }

Upvotes: 1

Related Questions