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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:25:51+00:00 2026-05-31T12:25:51+00:00

So I have a ChatsController, and from my index action, I’m trying to redirect

  • 0

So I have a ChatsController, and from my index action, I’m trying to redirect to a custom action, “decide”:

def index
  @chat = Chat.customfind(params[:search])
  if(@chat.is_a?(Array))
    session[:chats] = @chat
    redirect_to :action => 'decide'
  else
  respond_to do |format|
    format.html { redirect_to @chat if !@chat.nil? }
  end
end

def decide
  @chats = session[:chats]
  @choice = Chat.find(params[:id])
  redirect_to @choice if !@choice.nil?
end

..where @choice is going to be decided by the params of the form on the decide page. But for some reason, instead of redirecting to decide, Rails redirects to show:

Started GET "/chats/decide" for 127.0.0.1 at 2012-03-14 17:13:36 -0400
  Processing by ChatsController#show as HTML
  Parameters: {"id"=>"decide"}
  ..............

Can anyone explain how to fix this?

Edit:
I’m assuming this is what you want… the relevant parts of my routes.rb:

match "chats/decide" => "chats#decide"

resources :chats do
  member do
    post 'send_message'
  end
end

get "chats/logout"

..yeah it’s a bit of a hodgepodge :/

  • 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-31T12:25:53+00:00Added an answer on May 31, 2026 at 12:25 pm

    It seems you are trying to achieve the following:

    • Find all chats matching a given search string
    • If 1 chat is found, redirect to it
    • If 2+ chats are found, redirect to /chats/decide so the user can pick one

    I would implement this as follows:

    1) Update routes.rb as follows:

    resources :chats do
      member do
        post :send_message
      end
    
      collection do
        get :decide # Produces the '/chats/decide/' route
      end
    end
    

    2) Change your chats#decide action to this:

    def decide
      @chats = session[:chats]
    end
    

    3) When you list the available chats in your decide.html.erb file, link them directly to the appropriate show link.

    4) Be explicit about your redirect in chats#index:

    redirect_to :controller => 'chats', :action => 'decide'
    

    Your chats#decide action should not respond differently based on whether it’s receiving an id or not. You can link directly to the specific chats in that view.

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

Sidebar

Related Questions

Have someone tried out DeCAL in Delphi 2009? I'm thinking about upgrading from 2007,
have not tested on windows. but in ubuntu when u disconnect from the network,
Have converted devise new session from erb to Haml but doens't work, this is
have been trying couple of hours now to make my iphone app universal. The
I want to place fields from a model in a select list. I have
Have one Doubt In MVC Architecture we can able to pass data from Controller
I have defined my helper function in Helper: module CarsHelper def my_helper ... end
Suppose I have an action in a controller like: public class ChartController { public
I have a ActiveRecord Car model: class Car < ActiveRecord::Base def check_value puts self.load_size
Have a n-tire web application and search often times out after 30 secs. How

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.