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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:05:08+00:00 2026-06-03T08:05:08+00:00

I have 2 models Users(devise gem) and Profiles where class User < ActiveRecord::Base has_one

  • 0

I have 2 models Users(devise gem) and Profiles where

  class User < ActiveRecord::Base
    has_one :profile

  class Profile < AciveRecord::Base
    belongs_to :user

Everything in the views of each model works fine, but I want to have a link_to in the application layout.

  <% if user_signed_in? %>
  <li><%= link_to current_user.username , profile_path(@profile) %></li>

But it shows me this error:

 ActionController::RoutingError (No route matches {:action=>"show", :controller=>"profiles"})

My profile controller

  def show 
  @profile = Profile.find(params[:id])

respond_to do |format|
  format.html # show.html.erb
  format.json { render json: @profile }
end

end

My rake routes:

            profiles GET    /profiles(.:format)                             profiles#index
                     POST   /profiles(.:format)                             profiles#create
         new_profile GET    /profiles/new(.:format)                         profiles#new
        edit_profile GET    /profiles/:id/edit(.:format)                    profiles#edit
             profile GET    /profiles/:id(.:format)                         profiles#show
                     PUT    /profiles/:id(.:format)                         profiles#update
                     DELETE /profiles/:id(.:format)                         profiles#destroy
    new_user_session GET    /users/sign_in(.:format)                        devise/sessions#new
        user_session POST   /users/sign_in(.:format)                        devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format)                       devise/sessions#destroy
       user_password POST   /users/password(.:format)                       devise/passwords#create
   new_user_password GET    /users/password/new(.:format)                   devise/passwords#new
  edit_user_password GET    /users/password/edit(.:format)                  devise/passwords#edit
                     PUT    /users/password(.:format)                                            devise/passwords#update

 cancel_user_registration GET    /users/cancel(.:format)                    registrations#cancel
        user_registration POST   /users(.:format)                           registrations#create
    new_user_registration GET    /users/sign_up(.:format)                   registrations#new
   edit_user_registration GET    /users/edit(.:format)                      registrations#edit
                          PUT    /users(.:format)                           registrations#update
                          DELETE /users(.:format)                           registrations#destroy

I want that the link displays the currentuser.username ( I have Devise Username already) and link to the profile page of the current_user.

Thanks!

  • 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-03T08:05:10+00:00Added an answer on June 3, 2026 at 8:05 am

    It looks like you’re not setting @profile in the actions that actually use the layout, so it’s coming up as nil, and the router needs an id to generate the route.

    You need to be setting @profile to something in any action that renders with the application layout. This is possibly a job for a global before_filter.

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

Sidebar

Related Questions

I have 3 models sites, user_favorites and users. Relevant relationships: class Site < ActiveRecord::Base
I have three models: class Book < ActiveRecord::Base has_many :collections has_many :users, :through =>
I'm using Devise and have models set up like this: User has_one :profile Profile
First here's my current setup: models/user.rb class User < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable,
I have these models: class UserProfile(models.Model): user = models.OneToOneField(User) #etc class Organization(models.Model): users =
I have two models User and Admin(with RailsAdmin) that use Devise. I sign in
I have two models - Tenant and User, each tenant will have_many users and
Right now, I have three models Post, Comment and User (using Devise ) associated
I have one model User with Devise gem. I added a new field called
I have separate models for Devise users and admins. I am also using Basecamp

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.