Daði Hall Daði Hall - 2 months ago 11
Ruby Question

How can I access the profiles/show.html.erb in rails app

I´m using Devise, and after signing up, I want my users to access the

profiles/show.html.erb


I have an
registrations_controller.rb
and in there I have this piece of code

def after_sign_up_path_for(resource)
new_user_profile_path(current_user)
end


It directs the user to
profiles/new.html.erb
but I want the user to go to
profiles/show.html.erb


the
rake routes
shows this paths:

new_user_profile GET /users/:user_id/profile/new(.:format) profiles#new
edit_user_profile GET /users/:user_id/profile/edit(.:format) profiles#edit
GET /users/:user_id/profile(.:format) profiles#show


how would I modify this chunk of code to direct to the
profiles/show.html.erb
?

I'm to unexperienced to figure this out by my self, any help would be greate

this is my
routes.rb
file

Rails.application.routes.draw do
devise_for :users, :controllers => { registrations: 'registrations' }
resources :users do
resource :profile
end


root 'pages#index'

end


** Edit**

the rake routes output


Prefix Verb URI Pattern Controller#Action
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
PATCH /users/password(.:format) devise/passwords#update
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
PATCH /users(.:format) registrations#update
PUT /users(.:format) registrations#update
DELETE /users(.:format) registrations#destroy
user_profile POST /users/:user_id/profile(.:format) profiles#create
new_user_profile GET /users/:user_id/profile/new(.:format) profiles#new
edit_user_profile GET /users/:user_id/profile/edit(.:format) profiles#edit
GET /users/:user_id/profile(.:format) profiles#show
PATCH /users/:user_id/profile(.:format) profiles#update
PUT /users/:user_id/profile(.:format) profiles#update
DELETE /users/:user_id/profile(.:format) profiles#destroy
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PATCH /users/:id(.:format) users#update
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
GET /%20/users/:user_id/profile(.:format)%20 profiles#show
root GET / pages#index

Answer

I fixed it, check your github. Spelling of your resource is wrong It should be resources :profile not resource :profile that is why it was not showing you the paths to the profile resources through rake routes command. I used the profile_path(current_user) in the show action at profile_controller.rb file