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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:24:44+00:00 2026-06-17T04:24:44+00:00

Just trying out a simple rails app, mostly going for an API backend with

  • 0

Just trying out a simple rails app, mostly going for an API backend with JSON, heavy client side app. So what i want to do is only render the layout, and have javascript code handle the url, and make the ajax request to get the json data. The following seems to work:

respond_to do |format|
  format.html { render :nothing => true, :layout => true }
end

However, since nothing is meant to render nothing, it feels kinda wrong. Is there a more proper way to just render the layout? Note that my layout does not have a yield.

  • 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-17T04:24:45+00:00Added an answer on June 17, 2026 at 4:24 am

    Try this, this will render the response to a file called sample.html which could be a static html file.

    and also you could have this file in a common location, so that you could loaded it to all the actions

    have your static content in this page, and if you need a dynamic page you could have a .erb page too

    in your method

    def index
        @posts = Post.all
    
        respond_to do |format|
          format.html {render :file => "posts/sample"}
          format.json { render json: @posts }
        end
    end
    
    /post/sample.html
    

    HTH

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

Sidebar

Related Questions

So I am just trying out the Jsoup API and have a simple question.
i just started learning swings. And thought of trying out a simple program, but
I am trying out a very simple cpp program on osx just to get
I'm trying to do something very simple in my first Rails app (Rails 3)
Basically, Im just trying out a very simple collision test for another program Im
I am currently trying to incorporate attributes in the API of my Rails app.
i'm just trying to work out a simple way opening, editing and saving an
Lost a bunch of time just trying to figure out what was going on
I'm new to iPhone development and I'm just trying out some simple drawing routines
Just trying out Hibernate (with Annotations) and I'm having problems with my mappings. I

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.