ruby on rails - Why is my json not appearing in my params? -
in rails app, have:
routes.rb:
resources :tasks, :defaults => {:format => 'json'}, :except => [:index, :new, :create, :show, :edit, :update, :destroy] member :to_chrome post :from_chrome end end
mime_types.rb:
mime::type.register "application/xls", :xls mime::type.register "application/json", :json
tasks_controller.rb:
class taskscontroller < applicationcontroller skip_before_action :verify_authenticity_token, if: :json_request? def to_chrome @survey = survey.find(params["id"]) @survey = survey.last respond_to |format| format.json {render_for_api :private, :json => @survey} end end end def from_chrome binding.pry_remote render :nothing => true end protected def json_request? request.format.json? end end
to_chrome
working fine.
i'm trying trigger from_chrome
postman following settings:
url: http://localhost:3000/tasks/2452456/from_chrome
verb: post
body: "john rambo", time:"2pm"
(have tried wrapping entire string in single quotes)
body format: raw json (application/json)
header 1: accept: application/json
header 2: content-type: application/json
in postman, i'm getting 200 response.
but in rails, when inspect params
inside from_chrome
, see:
{"format"=>"json", "controller"=>"tasks", "action"=>"from_chrome", "id"=>"2452456"}
where's json?
thanks,
steven.
never mind. found json in request.body.read
.
Comments
Post a Comment