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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:13:27+00:00 2026-05-31T09:13:27+00:00

So I am trying to make a link to user’s profile! So I have

  • 0

So I am trying to make a link to user’s profile! So I have this in User’s controller:

class UsersController < ApplicationController

  def new
    #defining the "@user" object for the form_for
    @user = User.new    
  end

  #defining a function for the "show" html file
  def show
    #get user id by URL address
    @user = User.find(params[:id])
  end

  #handling user login succes or failure
  def create
    @user = User.new(params[:user])
    if @user.save

        #using "flash" variable Ruby
        #flash[:success] = "Welcome to the Sample App!" <<< use this !!

        #render success page
        redirect_to @user
    else
        #render failure page (using error partial page)
        render 'new'
    end
  end

  #mine to show user profile
  def show_user

    render 'show'

  end
end

and in my routes.rb I got:

DemoApp::Application.routes.draw do

  get "intergration_test/authentication_pages"

  #Removed!
  #get "users/new"

  #ROOT page 
  root to: 'static_pages#home'

  #My routes
  match '/user_profile', to: 'users#show_user'

  #REST architecture for users
  resources :users

  #including the Sessions action
  resources :sessions, only: [:new, :create, :destroy]

  match '/signup',  to: 'users#new'
  match '/signin',  to: 'sessions#new'
  #Note the use of via: :delete for the signout route, which indicated that it should be invoked using an HTTP DELETE request
  match '/signout', to: 'sessions#destroy', via: :delete

end

So why does

  #mine to show user profile
  def show_user

    render 'show'

  end

returns me the error:

undefined method `email' for nil:NilClass

it is like the user is null! I am already logged in! so I should have a user active.
even if I use redirect_to @user it does not work! help?

  • 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-31T09:13:28+00:00Added an answer on May 31, 2026 at 9:13 am

    I’m assuming the show template has access to ‘user’ via the @user instance variable. If so, then you need to set the instance variable:

    def show_user
     @user = current_user // Or other method for getting the logged in user. 
     render 'show'
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm new with RoR and i'm trying to make a master-datail: User -Lugar(place) My
I am new MVC user and I am trying to make shopping cart as
I am trying to make a post on another user's wall using another user
I'm trying to make logging for my rails app and have some dilemmas over
I am trying to make it so that when the user selects something via
I'm trying to make my app post on the user's wall. Under the post
I am trying to make dynamic function where user can create list without adding
I'm trying to make a nice visual effect so the user can actual see
I'm trying to make a simple link that will toggle my status attribute in
I'm trying to make a jquery tooltip that appears when a user mouses over

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.