Part 2

Please note, an installation of ImageMagick is required for this lesson. We recommend using Homebrew to install this on OS X For Windows and Linux, please see the instructions on these pages: * http://www.imagemagick.org/script/binary-releases.p...
This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/intermediate-part-2
1 Like

Hereā€™s a SO post that helps clarify some issues you may run into with Rails 4 about halfway through the video:

Also, Paperclip has a content type validator that I couldnā€™t get working until I discovered this:

1 Like

Looks like thereā€™s a better workaround for validations:

In Rails 4, when you run the migration for the following_relationships table, you wonā€™t be able to do it!

You have to jump a head a bit in the video and add more relationship logic to your User model before the migration will run.

Did you manage to make this work?

Hi @ryankbales, that error means that you are trying to render a nil, rather than the object you expect to have. Many of ActiveRecordā€™s finder methods will return nil if they fail to find a record, for instance User.find_by(email: 'fake-email') would return nil rather than a user (or raising an error).

You can force Rails to raise an error if you expect a user to be there, and not having one would be a problem. Just tack a ! on the end of the method name User.find_by!(email: 'fake-email')

All together this looks like:

# in your controller
@user = User.find_by(email: 'not-a-real-email') # => returns nil

# in your view, you expect @user to be a User object, but it is actually nil
<%= render @user %>

Okey dokey. After realizing that part of the solutions were already posted here, I finally got it working with one last stepā€¦Upgrading Imagemagick. Thanks for the help.

Iā€™m not getting any errors, but the shouts wonā€™t render on my dashboard show page, and on my user show page itā€™s listing the shout objects themselves <TextShout:0x007f83a96486b8> instead of the content. Iā€™ve checked my code several times and as far as I can see, itā€™s identical to the video. Shouts are being created properly so my polymorphic association is setup correctly, but I must be missing something with rendering the partials. Iā€™m on Rails 4.2.1, if that makes any difference for this specific issue.

@samjulien Thanks for the so post. It solved my problem

Did you fix this error already? Im having the same problem

Hey there folks, I have a two small problems with my application.

  1. My objects are not rendering, PhotoShout and TextShout I just get the reference to the object but not the content itself #<PhotoShout:0x007fe12a1f9e98> when I click on their show page

  2. I canā€™t manage to display the gravatar photo on the user I just get an empty reference. Does the actual user must already have a gravatar profile created? I just get E64c7d89f26bd1972efa854d13d7dd61?s=48

My image does not show up on the dashboard. It is just a ā€œbroken photo linkā€ icon. If I click on it, it goes to the full size image just fine.

partial

<%= link_to image_tag(photo_shout.image.url(:shout)), photo_shout.image.url %>

model

class PhotoShout < ActiveRecord::Base
  has_attached_file :image, style: {
    shout: '200x200>'
  }
end

Anyone else have this issue?

That was it. Thanks!

Happy to helpā€¦ glad you caught it before akimet flagged it as potential spam too lol

Hey guys! Iā€™m at the end of video 2 for the ā€˜Shouterā€™ app, and Iā€™m having a little trouble saving followed_users and followers to the db. Iā€™ve tried to use Devise for authentication instead of Monbon, and believe the create method in my FollowingRelationships can controller is the issue. Anyone else tried to use Devise and find a work around? Hereā€™s the link to my repos. Iā€™ve tried to nut this one out myself but canā€™t find a solution!! GitHub - RuNpiXelruN/upcase_intermediate: Intermediate Upcase walk-through

I think this:

devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable

needs to come before you declare associations in the User model