I'm a Rails newbie making my way through Michael Hartl's Ruby on Rails Tutorial and, while I have been able to troubleshoot a few errors on my own, this one from my trek through chapter 9 is sending me in circles.
(What I assume are) the relevant parts of the Users controller:
class UsersController < ApplicationController
before_action :logged_in_user, only: [:index, :edit, :update]
before_action :correct_user, only: [:edit, :update]
def index
@users = User.all
end
My views/users/index.html.erb
:
<% provide(:title, 'All users') %>
<h1>All users</h1>
<ul class="users">
<% @users.each do |user| %> # Line flagged with error
<li>
<%= gravatar_for user, size: 50 %>
<%= link_to user.name, user %>
</li>
<% end %>
</ul>
My Users helper:
module UsersHelper
def gravatar_for(user) # line flagged with error
gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
gravatar_url = "http://ift.tt/1d642xH}"
image_tag(gravatar_url, alt: user.name, class: "gravatar")
end
end
The error also flags another line of code that doesn't exist in my files; I guess it comes from the Ruby to HTML conversion?
delegate :to_xml, :to_yaml, :length, :collect, :map, :each, :all?, :include?, :to_ary, :join, to: :to_a
I've been scratching my head at this for almost two hours with no progress. All I know is that these errors go away when I replace the index page with simple text. Is this a problem with Gravatar? I really have no clue and would appreciate any help.
Aucun commentaire:
Enregistrer un commentaire