William Kennedy

Joined

28,280 Experience
244 Lessons Completed
5 Questions Solved

Activity

There is a video on that.

https://gorails.com/episodes/datatables-from-scratch-using-hotwire?autoplay=1

Combine what you learned here with filtering and using the pagy gem and you should be good to go

You can always call to_sql to see what the SQL is at the end of every query

Posted in What's with the elitism against Javascript?

People spend a long time using a programming language. Each language has its own libraries and cultures of people. It forms part of a person's identity. Anything that is different can be a threat.

That's my two cents.

Posted in Pattern for Managing Third Party Integrations

Hey Matt,

A pattern I've used is to create a folder called api_clients/ with subfolders for each api_wrapper.

For example, on one project, I did the following

api_clients/
--/xero
--/fitbit
--/stripe

Each of these folders contain the code I need to integrate with the apis. I generally organize each folder with like this https://github.com/williamkennedy/tryterra_api/tree/main/lib/try_terra

The aim is that I would be able to call something like

client = Xero::Client.new
client.invoices => Xero::Invoices class

Hope that helps.

Posted in Realtime Nested Comments: Part 3 Discussion

In scenarios, like this, I use the user method on the object. Since the comment.user will return the correct user for that comment.

It depends on how many threads you can handle on your system. So I would imagine there is probably an upper limit. They addressed this in the PR https://github.com/rails/rails/pull/40037#discussion_r571920259

Basically, having it as default might lead to unintentional consequences. Whereas, using it for queries that are exceptionally long might be the best fit for it.

Posted in How to use jQuery & jQueryUI with Esbuild Discussion

Should do. You have to make sure to import jquery first after the yarn install

import jquery from 'jquery';
window.jQuery = jquery;
window.$ = jquery;

There are a few jobs boards available. Even GoRails has one https://jobs.gorails.com/

It's also worth subscribing to newsletters such as Ruby Weekly and of course, creating a good LinkedIn will always help.

The key thing is to learn how to market and position yourself which makes the job hunt easier.

Posted in F.submit not creating object

Hey Samantha,

Can we see the rest of your form?

You may have a nested form (as in a form within a form) or your f.submit is outside of the actual form_for block

Hey George,

Yes. Jumpstart pro comes with an API setup that makes it easy to get started with someting like a React Native frontend. I'm actually building a React Native app for my app as well.

You do have to setup things like tailwind for a new React App and architect the react native app yourself but getting setup was no problem for me.

Thanks,
William

Posted in Multiuser Live Video Chat in Rails Discussion

The last part reminded me of the Brady Bunch. https://youtu.be/B7P6vEgMr4g?t=1027

Cool video(s)

Nice video Chris.

I did something similar on a project a while ago but not with the elegant stimulus js solution.

Something that I am wondering about Websockets. In terms of edges cases or pitfalls that one could fall into pretty easily, what are some good ones to look out for?

Posted in Issue deploying Rails app with capistrano

There are a few possible things going on here. Is your rails master key saved as an env varaiable?

ENV['RAILS_MASTER_KEY']

This is why the nil class error could be happening.

If you don't have the master key set then the following line won't work:

Rails.application.credentials.mysql[:username]

Try seeing if the master key ENV variable is set and just come back with any questions.

Posted in embed youtube in actiontext?

Hi ya na,

He did a whole talk about this.

https://railsconf.com/2020/video/chris-oliver-advanced-actiontext-attaching-any-model-in-rich-text

You can embed iframes into ActionText but you have to whitelist the iframe element.

##application.rb

config.to_prepare do
  ActionText::ContentHelper.allowed_tags << "iframe"
end

Posted in How to Test Validations in Rails Discussion

For validations, I sometimes like to use the shoulda-matchers gem

It's pretty cool because alot of use cases are set up already so it saves having to come up with the edge cases.

For example, in a model test (assuming Rails default not RSpec)
should validate_presence_of(:attribute)

For Rspec, you would write

it { should validate_presence_of(:attrinute) }

Obviously, it doesn't apply in some cases such as custom validate method but it's always a good start into a large codebase that might not have a massive test coverage.

I'm haven't watched the video and never used PurgeCss but I assume you would need to add matcher for .haml files.

/ postcss.config.js

let environment = {
  plugins: [
    require('tailwindcss'),
    require('autoprefixer'),
    require('postcss-import'),
    require('postcss-flexbugs-fixes'),
    require('postcss-preset-env')({
      autoprefixer: {
        flexbox: 'no-2009'
      },
      stage: 3
    }),
  ]
}

// Only run PurgeCSS in production (you can also add staging here)
if (process.env.RAILS_ENV === "production") {
  environment.plugins.push(
    require('@fullhuman/postcss-purgecss')({
      content: [

            // Matcher for haml
        './app/**/*.html.haml'

      ],
      defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || []
    })
  )
}

module.exports = environment

Posted in Stripe payments course getting out of date

Brilliant. I just happen to working on a project that needs to integrate payments. Looking forward to this.

For people that are asking about embedded signing,  I actually did this recently on a project. Basically, Docusign have an endpoint which returns the url for embedded signing. With the url, you simply redirect the customer off site to sign and then docusign will redirect them back to your app with a status. 


Create JSON like so 

signing_url_json = {
    userName: "something"
    email: email,
    recipientId: "1",
    clientUserId: 1,
    authenticationMethod: "email",
    returnUrl: url
}


Then post that JSON to the endpoint


"/envelopes/#{envelopeId}/views/recipient", signing_url_json.to_json


I can go into much more detail if people want me to. 

Posted in How do I transfer user data on delete

That's a good idea. Having a step-by-step process for deletion. Then you can just capture the new user who going to get everything transferred to. Best of luck. Hope I was able to help a little

Posted in How do I transfer user data on delete

Interesting. I think you could use callback for delete

class User < ActiveRecord::Base
  before_destroy :assign_courses

  private

  def assign_courses
    new_user = User.new_user_responible #some way of finding the next user responsible
    courses.update_all(user: new_user)
  end
end

Then you would just create a method for each table you want to transfer. 

assign_questions

You will also need to implement some scope on your User model to find the employee who is going to be assigned all the notes.