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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:39:38+00:00 2026-06-08T16:39:38+00:00

I am using rocket pants to render my JSON API. I’m trying to change

  • 0

I am using rocket pants to render my JSON API.

I’m trying to change the way it renders the JSON by overriding as_json in my model, but somehow, it seems not to change anything in the rocket pants response.

in my controller:

class Api::V1::ProjectsController < RocketPants::Base
  ...
  def show
    expose Project.find(params[:id])
  end
  ...
end

And in my model:

class Project < ActiveRecord::Base
  ...
  def as_json(options = {})
    {"this" => "is not working!"}
  end
  ...
end

What am I missing?

  • 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-08T16:39:39+00:00Added an answer on June 8, 2026 at 4:39 pm

    I’ve figured out how to do that. The way rocket pants work is by looking at the serializable_hash method. Overriding it results in a change in the response.

    Edit:

    The solution I got to:

    In the model where I need to add some attributes: simply override the attributes method:

     # Overriding this method is required for the attribute to appear in the API
      def attributes
        info = {} # add any logic that fits you
    
        super.merge info
      end
    

    In the controller that needs to expose the API I’ve created a new Model class (this is only needed in order to keep different API versions), and overridden the serializable_hash method:

      class Location < ::Location 
        def serializable_hash(options = {})
          super only: [:id, :lat, :long],
                include: [user: {only: ...your attributes here...}]
        end
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a common GWT application that is using (trying to) Rocket-Framework to implement
Using SQL Server 2008 R2 we are looking for a way to select the
I have this code i have been using....but i need a conditional where it
I have been using vb.net for a while. I am trying to figure out
I have been using jquery ui with no problem but just recently the jquery
I'm trying to figure out how when using the default asp.net forms authentication stuff
i'm trying to compile a c program using the berkeley db library (libdb) on
I am using XNA my rocket is creating smoke objects when it fly. I
I cant able to update the status in facebook using the facebook rocket library
I just wrote this SerializationHelper class, but I can't believe this is necessary! using

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.