can't convert true into String

2019-09-12 01:54发布

问题:

I'm having some problem with what I think is my cache.

I'm getting this error message:

ListsUsersController# (ActionView::Template::Error) "can't convert true into String"

Here is the code:

%footer
  - cache "footer-movies-#{Time.now.hour.to_s}", expires_in: 2.days do
    .foot-movies
      %ul
        - Movie.footer.each do |movie|
          %li= link_to (image_tag movie.poster, size: "60x92"), movie_path(movie), title: movie.title

It's complaining about line 40, which is the line containing .foot-movies.

The code works most of the time, but sometimes raises this error. I've not seen it my self in a while, but Exceptional tells me that the error has been raised over 500 times the last 7 days.

I'm using:

  • haml 3.1.2
  • rails 3.1
  • memcached 1.4.5
  • dalli 1.0.5

Here is the full stacktrace.

回答1:

One of the variables or methods you have doesn't have a string in it its simply 'true' and ruby wont convert that to a string. You'd have to hunt down which of these it is and make sure its passing the right value