Created
February 3, 2012 17:33
-
-
Save ch1ago/1731302 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
<jarr0dsz> im having a @group.participants.order(:id).offset(0).limit(1).first that returns a participant object i checked with .inspect but how do i get an attribute from that? | |
first_participant = @group.participants.order("id").select("name").first || :no_participant_for_this_group | |
if first_participant == :no_participant_for_this_group | |
puts first_participant.name | |
else | |
puts first_participant.name | |
end | |
-- | |
even if you don't put that if statement to validate... | |
and if there are no participants, it will generate an exception | |
with the name :no_participant_for_this_group on the log file, | |
witch will make your life easier to search for that code ;) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment