Created
March 27, 2014 18:54
-
-
Save adambray/9815242 to your computer and use it in GitHub Desktop.
Tunr purchases create action
This file contains 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
# | |
def create | |
song = Song.find(params[:song_id]) | |
if !current_user.songs.include?(song) | |
# This line here is failing for some reason. | |
# I expect to get true or false, but I'm getting a | |
# nilMethodError. | |
if current_user.debit(song.price) | |
@purchase = Purchase.create({ | |
song: song, | |
user: current_user, | |
price: song.price | |
}) | |
end | |
end | |
redirect_to songs_path | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment