Did I forget to do a migration?
I have a profile model and controller in Rails, and it works all well and good except when I call profile_path or simply "profile". I try and create:
<%= link_to current_user.profile_path %>
and instead of loading a link to the current user's profile path, I get:
PG::UndefinedTable: ERROR: relation "profiles" does not exist LINE 8: WHERE a.attrelid = '"profiles"'::regclass
Also, in my schema.rb I have nothing mentioning any to profile or profiles. I'm not sure if this helps, but here are my models and controllers.
class Profile < ApplicationRecord belongs_to :user end
class User < ApplicationRecord has_one :profile dependent: :destroy end
class ProfileController < ApplicationController skip_before_action :configure_permitted_parameters, only: [:show] before_action :authenticate_user!, only: [:index, :follow, :unfollow] def show @user = User.find(params[:id]) end def index end end
Also a closer step to my issue is that I'm using a "notifications" gem (literally called that) for my notifications and this is what I have under it.
# Method name of user profile page path, in User model, default: nil self.user_profile_url_method = 'profile'
Also, I think this might be a database problem and can probably be fixed with a simple migration, but I'm not sure what to put in the migration to fix it.
path helpers like
profile_path are not methods on the User model. You can use
<%= link_to "Profile", profile_path %> in your view to link to a route that matches that name.
The Rails guides would be a good place to read through how they work: https://guides.rubyonrails.org/routing.html#naming-routes
This doesn't (and shouldn't) have anything to do with your database. The error makes it look like that because you were trying to call a method on a database object.