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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:37:15+00:00 2026-05-15T03:37:15+00:00

I try to do following: A user is on his profile page. Now he

  • 0

I try to do following:
A user is on his profile page. Now he edits his profile. He klicks on update and the data is saved.
Now I want to redirect the user to another kind of profile-edit-page.
I did the following in my users_controller.rb:

    def update
        @user = User.find(params[:id])

        respond_to do |format|
          if @user.update_attributes(params[:user])
            flash[:notice] = 'User was successfully updated.'
            if(@user.team_id != nil)
              format.html { redirect_to(@user) }
            else
              format.html { redirect_to choose_team_path }
            end
            format.xml  { head :ok }
          else
            format.html { render :action => "edit" }
            format.xml  { render :xml => @user.errors, :status => :unprocessable_entity }
          end
        end
      end


  def choose_team
    @user = User.find(params[:id])
  end

I created a view: /users/choose_team.html.erb

Now I get the following error:

undefined local variable or method `choose_team_path' for #<UsersController:0x1f56650>

So I added choose_team to my routes.rb:

 map.choose_team 'choose-team', :controller => 'users', :action => 'choose_team'

Now, after submitting my first edit form, it redirects me to http://localhost:3000/choose-team
and I get following error: Couldn't find User without an ID

What I want:
If a user has no team_id, he should be redirected to my choose_team.html.erb for choosing a team, else he should be redirected to his profile/show.
How to do this?

EDIT:
By writing format.html { redirect_to :action => "choose_team" } instead of format.html { redirect_to choose_team_path } it is working. But how can I get an url like /users/1/choose_team ? At the moment it is just /choose_team .

  • 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-15T03:37:15+00:00Added an answer on May 15, 2026 at 3:37 am

    You have to add your action like this:

    map.resources :users, :member=>{:choose-team=>:get}
    

    Because, if you have an action like index, which returns a collection of users than should be put in collection hash. If your action is specific to a user you have to add to the :member hash, now you will get an url like /users/1/choose_team

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

Sidebar

Related Questions

EDIT It appears the user has to enter some data for his profile, otherwise
I'm using the following to try and get the twitter timeline of a user.
I'm getting following error when I try to log onto phpMyAdmin. User * *
I'm trying to learn interfaces and want to try the following: Let's say I
Try open the following page in two different tabs in your browser. hit the
I want to do so that if user press return key on his keyboard,
I want to export collection in mongodb using shell command: I try the following
I'm trying to do the following: User goes to web page, uploads XLS file
I have a search page where user can submit queries that try to match
Scratching my head here... If I try the following with rails: User.limit(25).includes([:addresses]) I get:

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.