mardi 12 décembre 2017

How can I make the object path / url relate to object name?

I have the object like

class Book
  include Mongoid::Document
  include Mongoid::Timestamps
  field :name, type: String
  field :notes, type: String
end

My url to one of my object when I show it was like http://localhost:3000/coins/5a2e9e460d5fdd0a32153c31

How can I make the url relate to the object name (#{book.name}) like

http://localhost:3000/coins/harrypotter

or

http://localhost:3000/coins/mazerunner

or

http://localhost:3000/coins/coolbook

Aucun commentaire:

Enregistrer un commentaire