Mysql Usersshow中的NameError

Mysql Usersshow中的NameError,mysql,ruby-on-rails,passenger,production,Mysql,Ruby On Rails,Passenger,Production,显示/home/bdme551/bdme21/app/views/users/show.html.erb,其中第6行出现: undefined local variable or method `size' for #<#<Class:0x007fb271759100>:0x00000003b579a0> Extracted source (around line #5): def gravatar_for(user, options = { size: 8

显示/home/bdme551/bdme21/app/views/users/show.html.erb,其中第6行出现:

undefined local variable or method `size' for #<#<Class:0x007fb271759100>:0x00000003b579a0>
Extracted source (around line #5):

      def gravatar_for(user, options = { size: 80 })
        gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
        gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}"
        image_tag(gravatar_url, alt: user.name, class: "gravatar")
      end
    end
我的名字有误。有人能帮我吗?谢谢。

您应该使用to options[:size]调用size,因为您正在传递options参数的哈希值

而不是:

gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}"
尝试:


我在下面补充了答案。
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{options[:size]}"