0

I am doing the exersizes of https://www.railstutorial.org/book. I am facing an issue in Chapter 7 at 7.1.4 "A gravatar image and a sidebar" section. Even I have made the appropriate code changes, no gravatar is showing on https://rails-tutorial-zovasilei.c9users.io/users/1. Only the name and the email of the user (with no gravatar) is showing on https://rails-tutorial-zovasilei.c9users.io/users/1.

I am working on cloud9 environment. The app is behaving such as the code has not been refreshed. Thus, I checked that the files have indeed been saved, and double-checked the code, but I do not understand which is the issue as no gravatar still appears.

I quote the code of some files:

routes.rb

Rails.application.routes.draw do
  root 'static_pages#home'
  get  '/help',    to: 'static_pages#help'
  get  '/about',   to: 'static_pages#about'
  get  '/contact', to: 'static_pages#contact'
  get  '/signup',  to: 'users#new'
  resources :users
end

app/views/users/show.html.erb

<% provide(:title, @user.name) %>
<h1>
  <%= gravatar_for @user %>
  <%= @user.name %>
</h1>

app/helpers/users_helper.rb

module UsersHelper

  # Returns the Gravatar for the given user.
  def gravatar_for(user)
    gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
    gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}"
    image_tag(gravatar_url, alt: user.name, class: "gravatar")
  end

app/controllers/users_controller.rb

class UsersController < ApplicationController
  def new
  end

  def show
    @user = User.find(params[:id])
  end

end
zoe vas
  • 281
  • 9
  • 25
  • i've tested your `gravatar_for(user)` and it's working. you sure that user's email is registered through gravatar and indeed uploaded a photo? – mrvncaragay Oct 07 '16 at 20:46
  • Thanks for testing it. I have registered the user's email in gravatar and also uploaded a photo. It is weird. – zoe vas Oct 07 '16 at 20:51
  • I ran the code in my local repository not c9. maybe it has issues with c9 idk – mrvncaragay Oct 07 '16 at 20:55
  • Since you say that you tested it locally and you faced no issue, then I am thinking that cloud9 is to be blamed for. I will recheck the files in cloud9. – zoe vas Oct 07 '16 at 20:58

1 Answers1

0

I solved the issue. I have forgotten in custom.scss:

img {
  display: none;
}

This tutorial in a previous chapter instructs to set img to none. But this css rule should be removed so as the gravatar image to be visible.

zoe vas
  • 281
  • 9
  • 25