I am looking to see how I would set up my :notice to incorporate a helper method, at the moment I have this and get 'undefined method to_dollars':
notice: "Thank you for your payment of #{to_dollars(amount)}"
Controller
def create
@donation = @campaign.donations.create(donation_params)
if @donation.save_with_payment
amount = @donation.donation_amount
redirect_to @campaign, notice: "Thank you for your payment of #{to_dollars(amount)}"
else
flash[:notice] = @donation.errors
render :new
end
end
My helper method is simply (unless anyone has a better way of doing it)
def to_dollars(amount)
convert = amount / 100
number_to_currency(convert, unit: "$", separator: ".", delimiter: "")
end
All donation_amounts are saved in cents so just want to convert them to dollars.