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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:13:57+00:00 2026-05-20T10:13:57+00:00

Given a classic controller action. Have a look at the MARK. I need to

  • 0

Given a classic controller action. Have a look at the MARK. I need to set the status code to 200 for the response. Background: swfupload an ajax file upload solution seems to send data in a wrong format.

I tried response.headers[‘Status’] = 200, response.status 200, render :json => ‘data’, :status => 200. But the response’s status code doesn’t change.

def create
  if params[:Filedata]
    @medium = Medium.new(:swf_uploaded_data => params[:Filedata])
  else
    @medium = Medium.new(params[:medium])
  end

  respond_to do |format|      
    if @medium.save  
      format.html { redirect_to(@medium, :notice => 'Medium was successfully created.'); }
      format.xml  { render :xml => @medium, :status => :created, :location => @medium; }        
      MARK
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @medium.errors, :status => :unprocessable_entity }
    end
  end
end
  • 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-05-20T10:13:58+00:00Added an answer on May 20, 2026 at 10:13 am

    The status code can only be declared within the return commands like render, redirect_to …. and will affect to this return command, there is no way to set the code for all the responses

    For format.html { redirect_to(@medium, :notice => 'Medium was successfully created.'); } since is a redirection the code will be a 3XX and you can’t change it or the redirection won’t work

    For format.xml { render :xml => @medium, :status => :created, :location => @medium; } you are declaring the status as created, this means for rails that the code is 201, for making it a 200 change it for:

    format.xml { render :xml => @medium, :status => :ok, :location => @medium; }

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

Sidebar

Related Questions

Given: I have a website that includes both ASP.NET Web Forms and Classic ASP
I need to call a web service from my classic ASP website. I have
Given a classic example of Student and Subject where they have a many-to-many relationship,
I have been tasked with obtaining a response from a SOAP request, using classic
One of those classic programming interview questions... You are given two marbles, and told
Given a classic DB structure of Orders has zero or more OrderLines and OrderLine
Given an html form like this: <form action='/example/' id='example_form' method='POST' name='example_form'> <fieldset> <legend>Example form</legend>
I have a couple of classic ASP pages that require a user to enter
I'm currently trying to run a classic ASP application which I've been given source
I have an Exel 2007 PivotTable using classic layout that has 2 row fields.

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.