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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:43:44+00:00 2026-05-31T21:43:44+00:00

I’m developing an android app, and I need to have a json response of

  • 0

I’m developing an android app, and I need to have a json response of the show view about a saved object. Trying that, I receive:

"SystemStackError (stack level too deep)"
app/controllers/segnalaziones_controller.rb:74:in `create'
app/controllers/segnalaziones_controller.rb:58:in `create'

Here is the “Segnalazione” controller

include Gft

class SegnalazionesController < ApplicationController

  load_and_authorize_resource  
  respond_to :json
  # GET /segnalaziones
  # GET /segnalaziones.xml
  # before_filter :authorize

  def index
    @segnalaziones = Segnalazione.order(:dataspedizione)
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @segnalaziones }
      format.json  { render :json => @segnalaziones }
    end
  end

  # GET /segnalaziones/1
  # GET /segnalaziones/1.xml
  def show
    @segnalazione = Segnalazione.find(params[:id])
     respond_to do |format|
       format.html # show.html.erb
       format.xml  { render :xml => @segnalazione }
       format.json  { render :json => @segnalazione }
    end
  end

  # GET /segnalaziones/new
  # GET /segnalaziones/new.xml
  def new
    @segnalazione = Segnalazione.new
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @segnalazione }
      format.json  { render :json => @segnalazione }
    end
  end

  # GET /segnalaziones/1/edit
  def edit
    @segnalazione = Segnalazione.find(params[:id])

  end

  # POST /segnalaziones
  # POST /segnalaziones.xml
  def create
    @segnalazione = Segnalazione.new(params[:segnalazione])
@user = User.find_by_id(session[:user_id])
@username = session[:user_name]
@segnalazione.user = session[:user_id]
    @segnalazione.dataspedizione = Time.zone.now
    @user.last_request_at = Time.zone.now
    @user.save
    respond_to do |format|
      if @segnalazione.save
         Gft.spedisci(
            @segnalazione.id,
            @username,
            @segnalazione.mood,
            @segnalazione.dove,
            @segnalazione.via,
            @segnalazione.dataspedizione,
            @segnalazione.descrizione,
            @segnalazione.immagine.url,
            @segnalazione.categoria1,
            @segnalazione.categoria2,
            @segnalazione.categoria3)
          format.html { redirect_to(@segnalazione, :notice => 'Segnalazione creata, verrà visualizzata su mappa fra qualche attimo') }
          format.xml  { render :xml => @segnalazione, :status => :created, :location => @segnalazione }
          format.json  { render :json => @segnalazione, :status => :created, :location => @segnalazione }

        else
          format.html { render :action => "new" }
          format.xml  { render :xml => @segnalazione.errors, :status => :unprocessable_entity }
          format.json  { render :json => @segnalazione.errors, :status => :unprocessable_entity }
        end
      end
    end

    # PUT /segnalaziones/1
    # PUT /segnalaziones/1.xml
    def update
      @username = session[:user_name]
      @segnalazione = Segnalazione.find(params[:id])
      respond_to do |format|
        if @segnalazione.update_attributes(params[:segnalazione])
          Gft.aggiorna(
          @segnalazione.id,
          @username,
          @segnalazione.mood,
          @segnalazione.dove,
          @segnalazione.via,
          @segnalazione.dataspedizione,
          @segnalazione.datarisoluzione,
          @segnalazione.descrizione,
          @segnalazione.immagine.url,
          @segnalazione.categoria1,
          @segnalazione.categoria2,
          @segnalazione.categoria3)
        format.html { redirect_to(@segnalazione, :notice => 'Segnalazione aggiornata') }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @segnalazione.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /segnalaziones/1
  # DELETE /segnalaziones/1.xml
  def destroy
    @segnalazione = Segnalazione.find(params[:id])
    @segnalazione.destroy
    Gft.elimina(@segnalazione.id)
    respond_to do |format|
      format.html { redirect_to(admin_url) }
      format.xml  { head :ok }
    end
  end

  def eliminadatarisoluzione
    @segnalazione.datarisoluzione = nil
  end
end

If I “localhost:3000/segnalaziones/2?format=xml”, the xml is showed.

If I “localhost:3000/segnalaziones/2?format=json” I receive again the error page (stack level too deep … )

I’ve tried this solutions, that doesn’t work:

http://dalibornasevic.com/posts/5-ruby-stack-level-too-deep-systemstackerror

SOLUTION:

Instead of:

 format.json  { render :json => @segnalazione, :status => :created, :location => @segnalazione }

I’ve used

 format.json  { render :json => @segnalazione.as_json(:only => [:user, :categoria1, :categoria2, :categoria3, :descrizione, :dove, :via]), :status => :created, :location => @segnalazione }

Help found here: http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/

  • 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-31T21:43:45+00:00Added an answer on May 31, 2026 at 9:43 pm

    This is the Stack Overflow Problem. You can check the stack size here on various platforms.

    ulimit command which basically provides control over the resources available to the shell and processes started by it, on systems that allow such control.

    You can see the current limits with ‘ulimit -a’:

    [mrblack@ /]# ulimit -a
    core file size          (blocks, -c) 0
    data seg size           (kbytes, -d) unlimited
    scheduling priority             (-e) 0
    file size               (blocks, -f) unlimited
    pending signals                 (-i) 15910
    max locked memory       (kbytes, -l) 64
    max memory size         (kbytes, -m) unlimited
    open files                      (-n) 1024
    pipe size            (512 bytes, -p) 8
    POSIX message queues     (bytes, -q) 819200
    real-time priority              (-r) 0
    stack size              (kbytes, -s) 8192
    cpu time               (seconds, -t) unlimited
    max user processes              (-u) 1024
    virtual memory          (kbytes, -v) unlimited
    file locks                      (-x) unlimited
    

    And, you can change the stack size using ‘ulimit -s’ command.

    ulimit -s 32768 # sets the stack size to 32M bytes

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put

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.