Skip to content

Instantly share code, notes, and snippets.

@adambray
Created March 27, 2014 18:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adambray/9815242 to your computer and use it in GitHub Desktop.
Save adambray/9815242 to your computer and use it in GitHub Desktop.
Tunr purchases create action
#
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