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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:37:19+00:00 2026-06-17T13:37:19+00:00

Below is the typical respond_to block im using in my controller respond_to do |format|

  • 0

Below is the typical respond_to block im using in my controller

  respond_to do |format|
    format.html # show.html.erb
  end

I want to restrict all mime-types except html(lets say).
Couldn’t come up with a solution, how is this possible? This block does nothing if the request is json, this is OK but what I want is to redirect any requests that are not html.

Thanks

  • 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-17T13:37:20+00:00Added an answer on June 17, 2026 at 1:37 pm

    The format object yielded by respond_to has all of the usual mime types (html, js, xml, etc), and it also has a catch-all mime type any that will handle everything else. So, in this case:

    respond_to do |format|
      format.html
      format.any { redirect_to :foo }
    end
    

    will use default rendering for html, and will redirect for everything else. See the docs for (a tiny bit) more information: http://apidock.com/rails/ActionController/MimeResponds/respond_to

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

Sidebar

Related Questions

I have been using the block of code below to supposedly stop sql injections.
All, I'm new to XSLT and facing a typical problem. Below is the problem
Using Xerces C++ I generated the typical C++ code from the below schema. Upon
I have a typical many-to-many relationship using has_many => :through , as detailed below.
Below am posting my jsp page. home.jsp <%@taglib uri=/WEB-INF/struts-bean.tld prefix=bean%> <%@taglib uri=/WEB-INF/struts-html.tld prefix=html %>
Below is my form. Using jQuery I load a <select> element based on value
Below, I want div A to act as a two column layout for it's
Typical Event Log message looks like below. There you can find very interesting fields
The typical header should be #!/usr/bin/env python But I found below also works when
I want to write a *.ini file in MFC. I know those typical methods

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.