I'm creating a _sell_ action that, when the user clicks on the SELL button it is triggered. The user must have available stocks ( != 0 ) of that specific company, so if the user have 0 stocks of this company, the button won't do anything. It should be like a form that do not let the user Sing Up unless he completes everything ( a red bar appears saying what he have to do ).
Here is the sell action code, on my controller.
team_id = 9
find_the_specific_row = current_user.user_stocks.find_by team: team_id
if find_the_specific_row.nil? or find_the_specific_row == 0
find_the_specific_row.update(:amount => find_the_specific_row.amount - 1)
Note that the space that is blank ( the if statement) is where I should write what i am trying to do