Reputation: 25368
Instead of using a row's id
field to generate slugs (like this):
class Person < ActiveRecord::Base
def to_param
[id, name.parameterize].join("-")
end
end
I want to be able to use a non-id field, like this:
class Person < ActiveRecord::Base
def to_param
[application_id, name.parameterize].join("-")
end
end
It's still an integer, but instead of doing a find based on the id
, it should do a find based on application_id
.
Upvotes: 0
Views: 108
Reputation: 1144
This is fine, but you'll have to amend your find code to use the application_id.
@people = People.find_by_application_id(params[:id])
This should solve your issue.
Upvotes: 1