I have a Rails 4 app that is using Bootstrap. I am creating a dashboard page that shows buttons that are color coded to represent the status of the tool it represents. The H
Probably this is not answer, but I will give my suggestions. First of all you don't need two actions making same things. Try this
Controller
def in_service
@tool.update(:in_service => params[:in_service])
@success = params[:in_service]
respond_to do |format|
format.html { redirect_to(root_path) }
format.js
end
end
In view add parameters to query
View
Don't need to listen ajax bindings
js.erb
<% if @success %>
$('.btn').addClass('.btn-success').removeClass('.btn-warning');
<% else %>
$('.btn').addClass('.btn-warning').removeClass('.btn-success');
<% end %>