samedi 9 décembre 2017

Rails 4 - why my controller action is executes both as html and as json response, as seen in the logs

I have a Rails 4 action with no respond_to block.But in the logs i can see that the action render twice - one for html and other for json.i am wondering whats causing this.

###my route code

get 'halls/:id' => 'home#show_by_location', as: :show_by_location

####my homecontroller code

def show_by_location
 ####logic logic and logic
end

####development/server log

Started GET "/halls/Sydney" for 43.242.228.212 at 2017-12-10 07:28:11 +0000
Cannot render console from 43.242.228.212! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by HomeController#show_by_location as HTML
  Parameters: {"id"=>"Sydney"}

  ########other logs removed.....
  .........
  ...again below is json rendering for same action




Started GET "/halls/[object%20Object]" for 43.242.228.212 at 2017-12-10 07:28:24 +0000
Cannot render console from 43.242.228.212! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by HomeController#show_by_location as JSON
  Parameters: {"id"=>"[object Object]"}

i dont think this is a good sign and this costs my server to process the same data that i really dont need.

Kindly help.

Aucun commentaire:

Enregistrer un commentaire