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

  • Home
  • SEARCH
  • 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 6189787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:28:25+00:00 2026-05-24T02:28:25+00:00

I have a model class that is not bound to Active record. class ProcessingStatus

  • 0

I have a model class that is not bound to Active record.

  class ProcessingStatus
    attr_accessor :status, :timestamp
  end

The model acts as a processing status holder and will eventually be returned to the calling method.

Since this is invoked as an active resource method, this needs to go back (serialized) as xml.
Here is my action method:

def activate
  @process_status = ProcessingStatus.new
  if Account.activate(params[:account])           
    @process_status.status = "success"
  else
    @process_status.status = "fail"
  end 
  respond_to do |format|
    format.html # index.html.erb
    format.xml  { render :xml => @process_status }
  end
end

This doesn’t seem to return a valid xml though.

If I try and output the @process_status like below

return render :text => "The object is #{@process_status}"

this is what I get:

The object is #<ProcessingStatus:0x00000005e98860>

Please tell me what I am missing.

Edit #1,

Based on the comment below, I modified my code to include the serialization libraries.

class ProcessingStatus 
  include ActiveModel::Serialization
  include ActiveModel::Serializers::JSON
  include ActiveModel::Serializers::Xml

  attr_accessor :status

  def attributes

    @attributes ||= {'status' => 'nil'}
  end
end

I am getting closer:) Now get the output as follows for .xml request.
but the value that I assigned is not reflected.

@process_status.status = "success" / "fail"

<processing-status><status>nil</status></processing-status>

but when i make a json request, it is appearing correct!

{"processing_status":{"status":"success"}}
  • 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-24T02:28:26+00:00Added an answer on May 24, 2026 at 2:28 am

    You need to define method to_xml in your model, or include Serialization module as below:

    class ProcessingStatus
      include ActiveModel::Serialization
    
      attr_accessor :status, :timestamp
    end
    

    Here you’ve got more info: http://api.rubyonrails.org/classes/ActiveModel/Serialization.html

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

Sidebar

Related Questions

I have a standard active record model with an attributes that is required: class
I have a class that has a Generic type G In my class model
I have one grails application.In that I have one model class named Book. From
I have three model classes that look as below: class Model(models.Model): model = models.CharField(max_length=20,
I have a class that contains data from some model. This class has metadata
I have a model that is something like this: class Input(models.Model): details = models.CharField(max_length=1000)
In my business model I have Entity class (IPoint interface ) that has a
I have a model called company that has_many users then users belongs_to company. class
I have a rails model that looks something like this: class Recipe < ActiveRecord::Base
I have a class in my domain model root that looks like this: namespace

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.