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 9200181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:42:29+00:00 2026-06-17T22:42:29+00:00

I am using rails 3.2.8 on Ubuntu 12.04 I am building a web service

  • 0

I am using rails 3.2.8 on Ubuntu 12.04

I am building a web service with json only support. Now if someone sends me data that is not json but sets content-type to application/json the rails application raises an exception and returns 500 (internal server error).

This exception happens within rails before the controller action is called as rails is trying to create the params structure and parse the incoming data as JSON.

I am not sure this is right behaviour. I would have prefered if it rescued the exception and let me know in some special handler or within my action with some variable set. I would want to indicate 415 (unsupported media type) or 422 (unprocessable entity). My guess is 422 is more appropriate in this case.

Any ideas on how this can be accomplished?

  • 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-17T22:42:31+00:00Added an answer on June 17, 2026 at 10:42 pm

    Guess you need to change middleware a bit. Either create custom middleware and insert it before ParamsParser, or override the ParamsParser.

    Take a look at this request, there is a sample of ParamsParser overriding.

    Creating custom middlevare has another advantage: if data is json but content-type is not application/json, you can fix it here (example).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I installed Ubuntu, GlassFish web server, installed JRuby on Rails using GlassFish's admin tools,
Using Rails 3.1.3 with Ruby 1.9.3p0. I've discovered that by default, Rails does not
I am using Ubuntu 12.04 and I have a rails application, that I would
When I'm using the Rails console in Ubuntu for a long session I define
Using Ubuntu, when I run bundle install to set up my Rails environment, it
I am using Ubuntu 9.04 I just installed ruby and rails in my system
Using Rails 3.2.2 and ruby 1.9.2 and I am not able to serve assets
I'm building a tablet app and my development environment is rails running ubuntu in
i am using rails server without any problem ubuntu 12.04. But I wanna try
Im using the following guide for getting started with rails for ubuntu 9.10. http://guides.rails.info/getting_started.html

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.