In my UI, I have a table of items. Each row has a favorite button. I am using button to make a rails call to add the db association.
I've been looking into how to check the result of the post response in my button to call.
If it succeeds, I want to disable the favorite button on my page and if it doesn't I want to nothing. Is there a way to check the post response in my button to call and is there a way to stay on the page?
Heres a sample of what I have
<%= button_to create_favorite_path(res.id), class: "favorite-btn-#{res.id} btn btn-default" do%>
<i class="glyphicon glyphicon-star-empty"></i>
<% end %>