Remote error: true using in RAILS, to POST a JS file

Asked

Viewed 34 times

0

I have a problem with my code, I want Rails to do remote: true of "Login" with a class and an id as below, but the server passes a GET, but I want to search the controller for the format.js to send a JS function of type POST, I need to know if the code of my view/index.html.erb below is correct:

In view/index.html.erb

in the controller: class Homecontroller < Applicationcontroller

  def index
    respond_to do |format|
        format.html
        format.js { }
  end
end

end

1 answer

1

Got a little confused the question, but what I understand is that you want the method index be a POST instead of GET.

By default the method index is used for requisitions GET. So what I recommend is you create another method and declare it in your file routes.rb it as a POST. And this method can give a render of the method index

def search
     render :action => :index
end

Browser other questions tagged

You are not signed in. Login or sign up in order to post.