I have a basic CRUD with "Company" model. To make the company name show up, I did
def to_param
name.parameterize
end
Then I accessed http://localhost:3000/companies/american-express
which runs show
action in the companies controller.
Obviously this doesn't work because the show
method is as following:
def show
@company = Company.find_by_id(params[:id])
end
The params[:id]
is american-express
. This string is not stored anywhere.
Do I need to store the short string (i.e., "american-express") in the database when I save the record? Or is there any way to retrieve the company data without saving the string in the database?