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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:39:56+00:00 2026-05-17T18:39:56+00:00

My problem is similar to the one in this question, but the opposite. How

  • 0

My problem is similar to the one in this question, but the opposite.
How do I specify ":layout => false" in Rails' respond_with?

The controller is sort of a file converter. It responds to many formats. One format is supposed to render an html layout showing metadata. This format need the layout to be rendered, unlike most other formats. Problem is I can’t convince Rails to render it.

class CustomFilesController < ApplicationController
  respond_to :all, :only => :show
  def show
    @custom_file = CustomFile.find(params[:id])
    respond_with(@custom_file) do |format|
      format.html {}
      format.xml {}
      format.json {}
      format.fil {
        puts '>>>>> IN FIL <<<<<'
        render :layout => true
      }
      format.any {
        file = @custom_file.as(:type => params[:format], :size => params[:size]) ## the REAL path to the file
        (file.nil? || @custom_file.nil?) ? head(:not_found) : send_file(file, :disposition => 'inline', :url_based_filename => true)
      }
    end
  end
end

I thought “:layout => true” would work but apparently not.

As you can see I have stripped away everything else in the controller before pasting it in here. The format “fil” is added to the mime types as a text/html format in config/initializers/mime_types.rb. I have my view file in place and it renders, but without any layout around it.

I would appreciate any advice. I have gotten nowhere for a while now and anything I find online suggests my code should work.

Thanks in advance.

  • 1 1 Answer
  • 4 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-17T18:39:56+00:00Added an answer on May 17, 2026 at 6:39 pm

    Found that the layout renders if I specify the exact path and filename of the layout file. In my case:

    render :layout => '/layouts/application.html.haml'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem is extremely similar to the one described in this SO question ,
(This question is similar to this one , but it's for using XMLHttpRequest instead
This question is similar to another one I asked , but whereas in that
This question may be very similar to my one, but I cannot see the
My problem is similar to the one described in this question: WPF MVVM Button
In a similar problem as the one showed in this question , is it
I guess this question is similar to this one , but asking again as
My question is similar to this one , but is different enough that I
I have a problem similar to this question but with an added complication: MySql,
My question is similar to this one , but more complicated. I am trying

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.