I have a link on my control panel this link, call an action of my controller.
<%= link_to "Enviar Correos".html_safe, {:controller => "users", :action => "email_all_users"}, :method => "get", :html => {:style => "color:#FAA732;" } %>
the action:
def email_all_users
User.all.each do |u|
if !u.information.nil?
if !u.information.business
UserMailer.candidate_email(u).deliver
else
UserMailer.business_email(u).deliver
end
else
UserMailer.no_info_email(u).deliver
end
end
redirect_to "/users/#{current_user.id}", :flash => { :success => "Los correos fueron enviados" }
end
everything works great, but it's taking a lot of time, so after click on the link I would like to change the link for a loading image and then (when the action finish), I would like to show another imagen (done!) and then show the link.
I've never work with ajax. So I need some help.
Thanks in advance.