Ad

Kaminari How To Process Routes As Javascript

- 1 answer

I have an issue. I had a freelancer do some things with my code and he messed up some things. One of the main things is the pagination doesn't work. I checked my old files and it used to say this

Processing by HomeController#load_more_books as JS

Now it's giving me

Processing by HomeController#load_more_books as JSON

How do I change the processing back to Javascript? Thank you

Ad

Answer

Change the default format in your routes

get "/some-resource", to: "some_controller#some_method", defaults: {format: "js"}

or in you controller you can tell .json requests to respond to .js

#app/controllers/some_controller.rb
class SomeController
  def some_method
    respond_to do |format|
      format.json { render "some_js_template.js" }
    end
  end
end
Ad
source: stackoverflow.com
Ad