User profile won't display for current user

Hi, I’ve added a user (devise) and a profile to my app. The problem is
that I can’t display the profile for that user. It tells me that there
is No route matches [GET] “/profile/1”

I wonder if anyone can point out where I’m going wrong, and why?

routes.rb
Rails.application.routes.draw do
devise_for :users
resources :profiles
resources :appointments

root ‘page#home’
get ‘page/testimonials’
get ‘/signedinuserprofile’ => ‘profiles#signedinuserprofile’
#get ‘page/home’

profiles controller:
class ProfilesController < ApplicationController
before_action :set_profile, only: [:show, :edit, :update, :destroy]

GET /profiles

GET /profiles.json

def index
@profiles = Profile.all
end

def signedinuserprofile
profile = Profile.find_by_user_id(current_user.id)
if profile.nil?
redirect_to “/profile/new”
else
@profile = Profile.find_by_user_id(current_user.id)
redirect_to “/profile/#{@profile.id}”
end
end

application controller:
class ApplicationController < ActionController::Base

Prevent CSRF attacks by raising an exception.

For APIs, you may want to use :null_session instead.

protect_from_forgery with: :exception

def after_sign_in_path_for(resource)
“/signedinuserprofile”
end
end

sessions controller:
class SessionsController < Devise::SessionsController
#after_sign_in_path_for is called by devise
def after_sign_in_path_for(user)
“/signedinuserprofile” # here I provide the path for the user’s
profile
end
end

I think you would use GET /users/profile/1

source: http://guides.rubyonrails.org/routing.html

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs