Chris Oliver

Joined

266,990 Experience
25 Lessons Completed
292 Questions Solved

Activity

Z-index to the rescue! The Places Autocomplete was a lower z-index than the modal, so some CSS fixes that nicely by raising it over the z-index of the modal (which was 9999).

Create app/javascript/stylesheets/components/places.scss

// Raise z-index of Google Places Autocomplete higher than the modal z-index
.pac-container {
    z-index: 10000 !important;
}

Add the following to app/javascript/stylesheets/components.scss

@import "components/places";

I'm leaving for vacation on Thursday so I don't have much time, but if you've got some sample code I can run, send me an email. 👍

Posted in Law of Demeter - Question

Yeah, that is not equivalent there because you're not filtering the evalulations, only the skill. You need to have it in a single query.

DHH doesn't like the Law of Demeter, so I wouldn't worry too much about trying to follow it. He's written about it a few times: https://signalvnoise.com/posts/3341-pattern-vision

Posted in Law of Demeter - Question

I've never really agreed with the single method call (dot) advice, personally.

One thing, you don't need the .try because where will always return an ActiveRecord::Relation object which will always respond to first. It may or may not return a record, so anything you call after that would need to check if accuracy was nil.

A little cleaner version is to use find_by

# Returns an Evaluation
def accuracy
  evaluations.joins(:skill).find_by(skills: { code: 'ACC' })
end

Stimulus monitors for elements in the DOM, so it should apply to them in the modal. Have you added any debugging code to the Stimulus controller to verify it's finding the correct element and initializing the autocomplete correctly?

Posted in List of Ruby Gems by Category on Go Rails

Tools are located here: https://gorails.com/tool_categories/

I think I accidentally removed the links to the Tools section! Better add that back. 😬

Yep! Just make sure the cookie gets included in the request and that's it. 👍

Hey Maria! You should post this to https://jobs.gorails.com as well!

Sidekiq needs to be configured to process the mailers queue.

If you have the HTML ID in the URL (or sent as a param), you could use that in your turbo_stream.replace.

For example:

<% @cards.each do |card| %>
  <%= tag.div id: dom_id(card) %>
    <%= render partial: "cards/show", locals: { card: card } %>
  <% end %>
<% end %>
<%= turbo_stream.replace dom_id(card), partial: "cards/show" %>

That gives you a consistent ID across things.

Turbo Frames would expect you to have routes for the card show & edit and would handle this for you automatically as long as you had a resources :cards controller filled out with the matching frames.

Posted in Stripe connect issues

Yep, you will:

  1. Create an account with Stripe::Account.create()
  2. Save the account ID to your user
  3. Create an AccountLink so the user can be onboarded.

https://stripe.com/docs/connect/connect-onboarding

Posted in Stripe connect issues

Stripe recommends using AccountLink instead of OAuth. It's a bit easier and supports both Express and Standard accounts.

Check out the docs for that here: https://stripe.com/docs/api/account_links

Posted in Help parsing a string down to what I need it to be.

Does this work? https://stackoverflow.com/questions/54979195/passing-cookies-with-httparty

get_response = HTTParty.get(url)

cookie_hash = HTTParty::CookieHash.new
get_response.get_fields('Set-Cookie').each { |c| cookie_hash.add_cookies(c) }

response = HTTParty.post("http://localhost:3000/users/other_urls", {headers: {'Cookie' => cookie_hash.to_cookie_string }} )

Access to admin panel is forbidden due to Doorkeeper.configure.admin_authenticator being unconfigured.

Looks like you need to set that config option.

Yes, it uses a database used only inside the CI.

And you want to always run the CI even if your local tests pass. The CI environment may catch something you missed and is most important when you have multiple people merging changes together as it can be easy to miss something. Think of it as double checking your work constantly. 👍

Posted in Store a hash in a database

A json or jsonb column can save/load a hash pretty easily and sounds like it might work for what you need. I'd just be careful to store simple things like strings, numbers, arrays in it and not something like a Ruby object.

I'm not following. If you're making realtime updates on the page without refreshing, you're going to want the same for flash and toasts.

That's what we covered in this episode?

More RAM would help you run more Rails processes at once so you could serve more users at once, but each individual request will still need to be optimized to run as quick as possible. Caching & optimizing assets is still important and a bigger CPU can help process requests slightly faster.

Posted in How to handle flash messages with TurboJS?

You can use a turbo stream to insert the flash message into a div for them. 👍

I'm actually going to do a screencast on this shortly.

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.