I have a webhooks controller which listens for when a new customer is created in Shopify.
def customer_created_callback
@first_name = params[:first_name]
@last_name = params[:last_name]
@email = params[:email]
@customer = Customer.new(first_name: @first_name, last_name: @last_name, email: @email)
if @customer.save
redirect_to customers_url
else
puts "error"
end
end
I am wondering if I should be creating the customer in this controller action. It seems like I should be handling the customer creation in Customer#create. But I'm not sure if it's a good idea to be passing all these params to a new action.
What's a good example of where I should be redirecting_to? I thought the idea of a webhook is that it's happening in the background so no page is actually going to be rendered..
Hope those make sense.