In my app, users have the ability to favorite items (“listings”). To make it a smooth user experience, I’m handling the favoriting through ajax. The only problem is that the ajax isn’t rendering correctly.
The html.erb related to the favorite button is the following:
<div class="favorite-btn"><%= link_to "Save to Favorites", favorites_path(id: listing.id), method: :post, remote: true, class: "btn btn-danger btn-xs" %></div>
I created a create.js.erb with the following and similar code in a destory.js.erb that replaces the “Remove as Favorite” with “Save to Favorites”:
Any thoughts on where I’m going wrong with this?