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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:09:18+00:00 2026-06-11T03:09:18+00:00

I am trying to build a one page application and having trouble with Rails

  • 0

I am trying to build a one page application and having trouble with Rails routing. Basically I want everything within admin route to admin controller index but json rails to specific resource. I’ve tried

namespace :admin do
  constraints :format => 'html' do
    match '*path' => 'admin#index'
  end

  constraints :format => 'json' do
      resources :user, :items
  end
end

In this case path will match greedily and match /admin/users.json
If I move the :format => ‘json’ block up. It matches /admin/users

Looks like the constraints blocks I specify does not works at all.

Rails version 3.2.6
rake routes

/admin/*path(.:format)                        admin/admin#index {:format=>"html"}
admin_users GET    /admin/users(.:format)     admin/users#index {:format=>"json"}

/* other normal resources routes for admin users and admin items */

I have checked and there is no route /admin/users(.format) admin/users#index {:format=>”html”}

so looks like it is exactly what I think it would be. but somehow still does not works

Update:
I have managed to get it workings if it move the json block up
However if the html block is on top. It is still causing me problem. But I think it is good enough for me now. Thanks guys

The original problem is I used request.xhr? in the controller where I should have used respond_to

Update 2
Uhm not acutally working now when I go to /admin/users I got a Not acceptable error. Where I would think that the first rule wont be match and match the second rule.

  • 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-11T03:09:20+00:00Added an answer on June 11, 2026 at 3:09 am

    Does it work if you move the json block up and make the format segment mandatory for each json resource? In Rails 3.2 this happens by setting the format option to true:

    namespace :admin do
      constraints(format: "json") do
        resources :items, format: true
        resources :users, format: true
      end
    
      constraints(format: "html") do
        match "*path" => "admin#index"
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a list page like the one in the Computers sample.
I'm trying to build a basic ListFragment based application which transitions from one ListFragment
I'm building my first rails app and I'm trying to build the search page
I'm trying to build a layout for a blog-like application having: a fixed-position fixed-width
I'm trying build a method which returns the shortest path from one node to
I am trying to build RadioGroup in Android with one RadioButton checked by default.
I'm trying to build progress menu bar(similar to one on the piccsy investors http://www.piccsy.com/investors/
I'm trying to build a portal in which i have two pages , one
I am trying to build my own little toolbox for Vista. One of the
I have a site I'm trying to build and I've hit one little snag

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.