https://www.airpair.com/ruby-on-rails/posts/building-a-restful-api-in-a-rails-application
http://gunnarpeipman.com/2015/05/why-to-avoid-fat-controllers/
Move the code to Web API
If your views make requests to controller just to get and save JSON-based data
Then you should introduce API controller for this kind of requests