Dan Donche

Joined

760 Experience
5 Lessons Completed
0 Questions Solved

Activity

Posted in Push changes to Node packages to Heroku

Figured out the problem. I feel stupid now. I had accidentally removed
<%= javascript_pack_tag 'application' %>
from my application.html.erb file.

Posted in Push changes to Node packages to Heroku

Okay, full disclosure, I upgraded to Rails 6 without fully understanding the consequences of using Actiontext and Webpacker. It's all new to me. So in my folly, I changed some of the Trix css directly in the Node packages directory instead of making them in the actiontext.css file that lives in the asset pipeline.

I encountered some issues after I started putting my css into the actiontext.css file, so (probably like an idiot) I just pulled all the css from the Trix folder (leaving it empty) and put it into the actiontext one. It mostly worked okay for a week or so.

I don't know what happened to my app, but now I cannot see the Trix editor when I go to edit any model that uses actiontext.

I am wondering how I can reset to original Trix files and push the node packages to Heroku. I feel as though these were only pushed the first time I installed Yarn and Node on Heroku. I'm not fully understanding this process. Any help would be appreciated.

I remembered posting about this. I found this article on how to make the Trix toolbar sticky, in case anyone is interested.
https://tosbourn.com/sticky-trix-toolbar/

I managed to temporarily remove the file upload icon with css.

trix-toolbar .trix-button--icon-attach {
  display: none;
}

Posted in How to use ActionText in Rails 6 Discussion

If you have this issue, set this in node_modules/trix/dist/trix.css:

 .trix-button-row { 
   display: flex; 
   flex-wrap: wrap; 
   justify-content: space-between; 
 } 

Posted in How to use ActionText in Rails 6 Discussion

Anybody know how to make the trix editor look fine on mobile?

Posted in User Onboarding Progress Bar Discussion

I have a weird issue going on with this. I previously implemented the activity feed from another video. Now whenever a user achieves 100 percent progress in this onboarding profile, it updates the onboarding_completed_at column as expected. Only thing is rails automatically inserts a new Activity with empty values into the database, which throws errors on the user dashboard.

 (0.0ms)  begin transaction
  SQL (1.7ms)  UPDATE "users" SET "onboarding_completed_at" = ?, "updated_at" = ? WHERE "users"."id" = ?  [["onboarding_completed_at", "2019-07-23 05:54:51.413467"], ["updated_at", "2019-07-23 05:54:51.750723"], ["id", 3]]
  SQL (0.2ms)  INSERT INTO "activities" ("user_id", "created_at", "updated_at") VALUES (?, ?, ?)  [["user_id", 3], ["created_at", "2019-07-23 05:54:51.754118"], ["updated_at", "2019-07-23 05:54:51.754118"]]
   (13.4ms)  commit transaction

Here is the error. Specifically it is talking about hte lookup_context line:

undefined method empty?' for nil:NilClass

<% if @feed_items.any? %>
    <% @feed_items.each do |item| %>
      <% if lookup_context.template_exists?(item.eventable_type, "dashboards/types", true) %>
        <div class="row p-2">
          <div class="col-3 col-md-2">
            <% if item.user.image? %>

My module here is exactly like the one in the video, I have only added other steps. (Also, the :has_followed? method appears in my user model already, and it works. Nothing in my users controller calls for an Activity to be created. In fact, this only occurs in specific controllers where something like a comment or a new post is created.

Why might this be happening?

module UserOnboarding
    extend ActiveSupport::Concern

    def should_see_onboarding?
        !onboarding_completed_at? || onboarding_completed_at > 1.day.ago
    end

    def onboarding_percent
        return 100 if onboarding_completed_at?

        steps = [:image?, :bio?, :has_favorite?, :has_followed?, :has_topic?, :has_comment?, :has_review?]
        complete = steps.select{ |step| send(step) }
        percent = complete.length / steps.length.to_f * 100
        update(onboarding_completed_at: Time.current) if percent == 100
        percent
    end

    def has_favorite?
        favorites.any?
    end

    def has_topic?
        topics.any?
    end

    def has_comment?
        comments.any?
    end

    def has_review?
        reviews.any?
    end
end

Posted in Activity Feed From Scratch Discussion

So I managed to fix this by changing it from :destroy to :delete_all.
has_many :activities, as: :eventable, dependent: :delete_all

Posted in Activity Feed From Scratch Discussion

Is this something where I would need to use a cascade? I do not understand the differences.
*Update, it seems like the immediate events are not being deleted along with the listing as well.

Posted in Activity Feed From Scratch Discussion

I have my events set up. Some of the models I have are listings and reviews. Reviews belong to listings. If someone leaves a review for a listing, the event saves both the review id (as eventable_id) and the listing id (as parent_id). So I can link to both in the view.

My problem is that if I deleted the listing, the review event remains, and rails throws an error (can't find listing with id 25, for example).

Here is my listing model:

class Listing < ApplicationRecord
  belongs_to :user
  has_many :reviews, dependent: :destroy
  has_many :activities, as: :eventable, dependent: :destroy

My reviews model also has
has_many :activities, as: :eventable, dependent: :destroy

The issue I'm having is that the listing gets deleted, and the reviews and events associated with that listing get deleted. But the events associated with the reviews do not get deleted. Did I do something wrong in the association?

Posted in SEEKING FREELANCER, Colorado Springs, remote: true

Note: I would also be willing to transition from Carrierwave to Active Storage if that would make everything easier.

Posted in SEEKING FREELANCER, Colorado Springs, remote: true

I have a Rails app I built with 5.2. It's intended to be similar to Soundcloud in some ways, Spotify in others. I am using Carrierwave to upload audio files to Amazon S3. One of the things I would like to hire a more skilled developer for is 1) writing id3 tags to these audio files when they get uploaded and 2) figuring out why the track information doesn't display via Bluetooth. I would also like to accept more audio types than mp3, and perhaps convert them to mp3 on upload.

Note that this will lead to more work in the future as tasks become available that I don't have time to do.

Posted in Activity Feed From Scratch Discussion

Great video, man. I had originally figure out how to do this on my own, and was like, "that's me!" when you mentioned how not to do it. Thanks for showing an alternative to "if activity type is this, show this". I was able to refactor quite a bit of code.

Hey Chidozie, that is very helpful. I'm using the trix gem, though, I don't think I can edit the css. I may have to do it manually. 
I am trying to figure out how to add a scroll bar to the textarea in Trix. Any suggestions? I'm using the gem. If there is a lot of content in the textarea, you have to scroll all the way back up just to change a word to bold or italic, etc., and then scroll all the way back to where you were, if you can find it. You can try it out yourself right here. 

Posted in Liking Posts Discussion

Disregard. I wrote the code correctly here, but in my user.rb file I had it written as

 
 def favorited?(track)
    track.favorites.where(user_id: :id).any?
  end 


You would need to add a username column to your users table in the database and then everything else should be the same as in the video. 

Posted in Repost / Retweet / Reblog Discussion

This was just what I needed, man. I tried to build out this feature myself and I ended up making it way more complicated than it should have been. I also now understand a few more things about Rails, so thanks for this.