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

  • Home
  • SEARCH
  • 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 5945591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:42:12+00:00 2026-05-22T16:42:12+00:00

I am using Ruby on Rails 3. In my project I have many classes

  • 0

I am using Ruby on Rails 3. In my project I have many classes and some of those are stated in the routes.rb file like the following:

#routers.rb
resources :users

namespace "users" do
  resources :profiles
  ...
end

With the above code I can access the following URLs:

<my_web_site>/users/1
<my_web_site>/users/1/edit
...
# and also
<my_web_site>/users/profiles/1
<my_web_site>/users/profiles/1/edit
...

What I would like to do is to redirect some URL requests to others URL but if in the routes.rb file I redirect all those, some controller actions will not work properly because also those requests are redirected (GET, POST, …).

How can I solve this issue?

P.S.: I know that (maybe) my router statements are wrong, but at the moment I am looking for a easy solution too the problem. However suggestions about this matter are welcome.

  • 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-22T16:42:12+00:00Added an answer on May 22, 2026 at 4:42 pm

    Ok, looks like you want to set up a redirection that will only apply for to a given path and just one HTTP verb. This seems to be what you are looking for:

    #routers.rb
    resources :users
    
    match "/users/profile/:id" => redirect("/profiles/%{id}"), :via => :get
    
    namespace "users" do
      resources :profiles
      ...
    end
    

    Based on this routes every GETrequest hitting /users/profile/1 will be redirected to /profiles/1 while any POST, PUT or DELETE requests won’t be suffering the redirection.

    The :via param will execure the redirection only if the request method math the given value. It also accepts an array of verbs so, for example, you can redirect :via => [:post, :put]

    If you add more detailed information about the specific redirections that you need we can create a better example.

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

Sidebar

Related Questions

I have been using ActiveResource in my Ruby on Rails applications for some time,
Ive recently started using Ruby on Rails for a project of mine and have
We're thinking about using the rufus-scheduler gem on a Ruby on Rails project to
I am using ruby on rails with a MySQL backend. I have a table
I have created a blog application using Ruby on Rails which includes the ability
I'm using Ruby on Rails to develop a web application. I have a wiki
I am using capistrano to deploy my Ruby on Rails project. I am on
I am working on ruby rails project. I am using Rails 2.3.4 and ruby
How can I start using Rspec with an existing Ruby on Rails 2.3.5 project
I am considering ditching Ruby on Rails for my web-development pet-project and using a

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.