Christopher Guller


790 Experience
0 Lessons Completed
1 Question Solved


Posted in Why is this image_tag not working?

If I try and put this code:

  <% if %>
    <%= image_tag {resize: '150x150^', extent: '150x150', gravity: 'Center'}), class:"rounded-circle" %>
  <% else %>
    <%= image_tag("fallback/default-avatar-3.png", class:"rounded-circle") %>
  <% end %>

into one of my notification layout pages I only get:

Can't resolve image into URL: undefined method `to_model' for #<ActiveStorage::Variant:0x00007fdf8499d7a0>
Did you mean?  to_yaml

This works on every other page for me other than the ones for notifications. This also isn't the only thing that doesn't work. Any active storage image will get the same error even if it isn't the same tag. I have no idea what is causing this to happen and I don't really have a good idea of how to fix it. Any way of fixing this error?

Posted in 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


class User < ApplicationRecord
  has_one :profile dependent: :destroy


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])
  def index

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.

logo Created with Sketch.

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

© 2023 GoRails, LLC. All rights reserved.