how do I make the URL's in Ruby on Rails SEO friendly knowing a @vendor.name?

前端 未结 7 1785
你的背包
你的背包 2021-02-04 12:06

My application is in RoR

I have an action/view called showsummary where the ID has been passed into the URL, and the controller has used that to instantiate @vendor wher

7条回答
  •  不思量自难忘°
    2021-02-04 12:20

    I thought I'd mention String#parameterize, as a supplement to the tagged answer.

    def to_param
      "#{id}-#{name.parameterize}"
    end
    

    It'll filter out hyphenated characters, replace spaces with dashes etc.

提交回复
热议问题