Christopher Guller
Joined
Activity
Posted in Why is this image_tag not working?
If I try and put this code:
<% if notification.actor.avatar.attached? %>
<%= image_tag notification.actor.avatar.variant(combine_options: {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.
profile.rb
class Profile < ApplicationRecord
belongs_to :user
end
user.rb
class User < ApplicationRecord
has_one :profile dependent: :destroy
end
profile_controller.rb
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.