Last active
December 29, 2015 01:18
-
-
Save mcavallo/7591616 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Course < ActiveRecord::Base | |
def image_or_default | |
image.empty? ? 'default.jpg' : image | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i tried this as a helper, i was testing on user before my student class model and it worked , is this the same concept ?
def avatar_url(user)
avatar_url = user.avatar? ? user.avatar.url : "user_avatar_small.png"
end
and inside the view : <%= image_tag avatar_url(user) %>
what is needed to make your code work ? i have an avatar column in my user model