Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7885603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:06:50+00:00 2026-06-03T05:06:50+00:00

I have a controller method in Ruby on Rails 3 that accepts application/JSON as

  • 0

I have a controller method in Ruby on Rails 3 that accepts application/JSON as the content type. This all works as expected, but I actually do not want rails to automatically parse the JSON in the body of the POST request. This method is acting as a gateway and just shuttles the information in to a queue and could be quite large. I do not want to waste the time processing the data in to the @_params since it’s unnecessary.

I believe I could get around this by setting the content-type in the header of the request to something else, but I would like to be semantically correct for the HTTP requests.

How can I disable this functionality?

EDIT:
more specifically how can I edit this functionality for just this one route?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:06:51+00:00Added an answer on June 3, 2026 at 5:06 am

    Parameter parsing is baked pretty deeply inside actionpack’s lib/action_dispatch/middleware/params_parser.rb.

    I’d say the best you’re going to get away with is intercepting the request with Rack, something like this.

    In lib/raw_json.rb

    module Rack
      class RawJSON
        def initialize(app)
          @app = app
        end
    
        def call(env)
          request = Request.new(env)
          if request.content_type =~ /application\/json/i
            # test request.path here to limit your processing to particular actions
            raw_json = env['rack.input'].read
            env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
            env['rack.input'] = StringIO.new("raw_json=#{raw_json}")
          end
          return @app.call(env)
        end
      end
    end
    

    In config.ru, insert this before the call to run <your app name>::Application

    require 'raw_json'
    use Rack::RawJSON
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Ruby on Rails, I have an update method in a controller, that is
I have a controller method that returns a jSON object and in one calling
I have a controller method that is a little something like this: def suggestions
I have just optimised some Ruby code that was in a controller method, replacing
I have built a Ruby on Rails (2.3.8) application that allows users to track
First of all, I'm using Rails 3.0.6 and Ruby 1.9.2 I have a controller
i have a quetion about MVC routing. I have a controller method that is
My site is open to all but i have a controller with some method
I have built a blog application w/ ruby on rails and I am trying
I am using Devise with Ruby on Rails. I have a few pages that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.