So, I have the following form:
<%= form_tag url_for(:controller => 'profile', :action => 'follow_topic'), :remote => true do %> <%= hidden_field_tag :topic_id, topic_id %> <%= content_tag :button, :class => 'link', :onclick => "javascript:document.getElementById('followtopic#{Topic.find(topic_id).identifier}').innerHTML='Following...'" do %> Follow <% end %> <% end %>
and I'm trying to get the controller to treat it as JS instead of HTML. The funny thing is that I have a form like this in another place of the application, which seems to work fine, and the controller definitions are the same. I can not understand the problem. Any ideas on what I should check first?
def follow_topic @topic = Topic.find(params[:topic_id]) current_user.follows << @topic respond_to do |format| format.js end end
source share