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

I hate to ask the classic question of business logic in database vs code
Clearly C, C++ and Fortran are the classic GNU languages and have full support.
Problem: Given a matrix in which each row and each column is sorted, write
I'm trying to create a permutation of a multidimensional array in classic asp (vbscript)
I'm new to this community, but I've found it really useful time to time.
What's the problem I wanna test a before filter that render errors in XML
In this answer to a question about the definitions of NP, NP-hard, and NP-complete,
I am currently maintaining an in-house business tool for our company's timesheets and project
I apologize for the length of this post but I needed to include a
Is there an efficient algorithm to compute the smallest integer N such that N!

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.