0

我使用 Slim 来表达我的观点,并且有这个:

/ = render 'alphabet'

div class="house-list" data-pjax-container="true"
  - @houses.each do |house|
    = link_to house_path(house)
      .picture
        = image_tag "http://mylink.com/150/#{house.name.to_s.parameterize}-#{house.location_1.to_s.parameterize}.jpg"
      .info
        h4 = house.name
        p = house.location_1

现在,这是导致问题的 link_to 行,如果我将其替换为纯div文本,则一切正常,但使用 link_to 会导致:

syntax error, unexpected keyword_ensure, expecting end-of-input

关于什么是错的任何想法?

4

1 回答 1

2

在这种情况下,我很确定您需要将 a 传递do &block给此link_to

= link_to house_path(house) do
  .picture
    = image_tag "http://mylink.com/150/#{house.name.to_s.parameterize}-#{house.location_1.to_s.parameterize}.jpg"
  .info
    h4 = house.name
    p = house.location_1
于 2013-05-29T21:16:17.980 回答