Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Problem with treebook

So I deployed to heroku in postgresql and everything is fine but the problem is that when a user signs up and creates a new status it crashes because a new user doesn't have an avatar! Seems like that is how it was coded and heroku freaks out and doesn't know what to do so it gives back an error so i was wondering if there is a way around this like leave the avatar blank or sends the user to the upload avatar page to upload one? or even make this app work without an avatar! github.com/becasual/book

this is heroku logs

2014-02-04T03:05:15.516035+00:00 app[web.1]: Completed 500 Internal Server Error in 10ms
2014-02-04T03:05:15.518631+00:00 app[web.1]: ActionView::Template::Error ( isn't precompiled):
2014-02-04T03:05:15.518631+00:00 app[web.1]:     4:       <h1>
2014-02-04T03:05:15.518631+00:00 app[web.1]:     5:         <%= avatar_profile_link @status.user %>
2014-02-04T03:05:15.518631+00:00 app[web.1]:     7:         <small><%= time_ago_in_words(@status.created_at) + " ago" %></small>
2014-02-04T03:05:15.518631+00:00 app[web.1]: 
2014-02-04T03:05:15.518631+00:00 app[web.1]:   app/helpers/application_helper.rb:27:in `avatar_profile_link'
2014-02-04T03:05:15.518631+00:00 app[web.1]:     2:   <div class="span8 offset2">
2014-02-04T03:05:15.518854+00:00 app[web.1]:   app/views/statuses/show.html.erb:3:in `_app_views_statuses_show_html_erb__2435466097949961850_69873428811560'
2014-02-04T03:05:15.518631+00:00 app[web.1]:     6:         <%= @status.user.full_name %>
2014-02-04T03:05:15.518854+00:00 app[web.1]: 
2014-02-04T03:05:15.518854+00:00 app[web.1]:   app/controllers/statuses_controller.rb:22:in `show'
2014-02-04T03:05:15.518854+00:00 app[web.1]:   app/views/statuses/show.html.erb:5:in `block in _app_views_statuses_show_html_erb__2435466097949961850_69873428811560'
2014-02-04T03:05:15.518854+00:00 app[web.1]:   app/helpers/application_helper.rb:31:in `page_header'
2014-02-04T03:05:15.515824+00:00 app[web.1]:   Rendered statuses/show.html.erb within layouts/application (4.7ms)
2014-02-04T03:05:15.518631+00:00 app[web.1]:     8:       </h1>
2014-02-04T03:05:15.518631+00:00 app[web.1]:     3:     <%= page_header do %>
2014-02-04T03:05:15.518854+00:00 app[web.1]: 
2014-02-04T03:05:19.349758+00:00 app[web.1]: Started GET "/activities" for 76.94.149.228 at 2014-02-04 03:05:19 +0000
2014-02-04T03:05:19.352602+00:00 app[web.1]: Processing by ActivitiesController#index as HTML
2014-02-04T03:05:19.366025+00:00 app[web.1]:   Rendered activities/index.html.erb within layouts/application (5.8ms)
2014-02-04T03:05:19.366175+00:00 app[web.1]: Completed 500 Internal Server Error in 13ms
2014-02-04T03:05:19.368708+00:00 app[web.1]: ActionView::Template::Error ( isn't precompiled):
2014-02-04T03:05:19.368708+00:00 app[web.1]:     5: <% @activities.each do |activity| %>
2014-02-04T03:05:19.368708+00:00 app[web.1]:     4: 
2014-02-04T03:05:19.368708+00:00 app[web.1]: 
2014-02-04T03:05:19.368708+00:00 app[web.1]:     7:     <%= avatar_profile_link activity.user, {}, class: 'pull-left' %>
2014-02-04T03:05:19.368708+00:00 app[web.1]:     6:   <div class="media">
2014-02-04T03:05:19.368708+00:00 app[web.1]:     8:     <div class="media-body">
2014-02-04T03:05:19.368708+00:00 app[web.1]:     9:       <h4 class="media-heading"><%= activity.user.full_name %></h4>
2014-02-04T03:05:19.368708+00:00 app[web.1]:   app/helpers/application_helper.rb:27:in `avatar_profile_link'
2014-02-04T03:05:19.368916+00:00 app[web.1]:   app/views/activities/index.html.erb:5:in `_app_views_activities_index_html_erb___4368243972004031624_69873428986220'
2014-02-04T03:05:19.368708+00:00 app[web.1]:     10:       <small><%= activity.created_at %></small>
2014-02-04T03:05:19.368916+00:00 app[web.1]: 
2014-02-04T03:05:19.368916+00:00 app[web.1]:   app/controllers/activities_controller.rb:7:in `index'
2014-02-04T03:05:19.368916+00:00 app[web.1]:   app/views/activities/index.html.erb:7:in `block in _app_views_activities_index_html_erb___4368243972004031624_69873428986220'

I really need help on this i commented the lines that give me the error but i don't know how to resolve this solution because the question is if a user doesn't have an avatar put a fixed image instead! because when a new user is created it give me the error that it blank and the app just crashes because it doesn't know what to do when it doesn't grab an avatar image!

6 Answers

I really need help with this!

seems similar but the thing is it all works locally also but just when you deploy on heroku everything goes to shit!

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey Tony Kim what happens if you run the following locally:

RAILS_ENV=production bundle exec rake assets:precompile

i did that precompile locally would end up like this eatgroup.herokuapp.com

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey Tony Kim try adding gem "rails_12factor" to your production group in your Gemfile. That may fix your issues.