Can I make an array of links using link_to in Rails?

前端 未结 5 1917
予麋鹿
予麋鹿 2021-02-19 13:29

I have a list of values in url/title pairs that I\'d like to display. (More specifically, each object has its own list of links, some with 0, some with 1, some with more.) I w

5条回答
  •  醉酒成梦
    2021-02-19 14:13

    Rails will convert strings to be html safe by default. Your join call turns the links output into a string, which is why the text is then being escaped. Try adding .html_safe after the join call, which will tell rails that the text you are providing is html safe and so does not need to be escaped. There's more on how this works at: http://yehudakatz.com/2010/02/01/safebuffers-and-rails-3-0/

提交回复
热议问题