Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby

Avatar link appears broken

I am on the adding avatars lesson, when I add an image tag after the file_field to show the image, it appears broken on the page when I try to upload an image (I am using rails 4).

#views/devise/registrations.edit.html.erb file:


<div class="form-group">
    <%= f.label :avatar %>
    <%= f.file_field :avatar, class: "form-control" %>
    <%= image_tag @user.avatar.url(:thumb) %>
  </div>


#user model:                                                                                                                                                               

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
     :recoverable, :rememberable, :trackable, :validatable

has_many :logs

has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }

validates :name, presence: true

validates :username, presence: true
end

#Database migration:
                                                                                                                                            class AddAvatarToUsers < ActiveRecord::Migration
   def self.up
    add_attachment :users, :avatar
  end

  def self.down
    remove_attachment :users, :avatar
  end
end