Chris Oliver

Joined

291,390 Experience
86 Lessons Completed
296 Questions Solved

Activity

Posted in Iterating using css grid

One thing that can help is extracting out things into partials, that way you can see your code a bit clearer. Looks like you were on that path, but it's commented out. I try and do that from the very beginning and that makes sure I have my loops setup correctly.

Posted in Iterating using css grid

You've got 18 per page in your pagination. Then you're not using the slice you defined.

<% @gyms.each_slice(3) do |gyms| %>
  <% @gyms.each_with_index do |gym, index| %>

You see the second line where you're using @gyms a second time? That should be gyms

You're accidentally looping through each group of 3, then rendering all 18 for each of those groups. 😜

Posted in Subscriptions with Stripe Discussion

I've turned it into a separate course since Stripe changes so much and it's hard to maintain these videos. https://courses.gorails.com/payments-with-rails-master-class

Posted in Iterating using css grid

Tailwind isn't your typical framework. It's just classes that wrap like one line of CSS so you'll end up learning CSS really quickly and better this way I've noticed. That's how I taught myself grid in the last month actually.

Posted in Iterating using css grid

And actually, if I were using TailwindCSS for CSS grid, I would do the following and set the grid to 3 columns.

<div class="grid grid-cols-3">
  <% posts.each_with_index do |post, index| %>
    <div>
      <%= post.title %>
    </div>
  <% end %>
</div>

Posted in Iterating using css grid

Yep, makes sense. You need to slice the array into groups of 3, then loop through each one of those instead.

<% @posts.each_slice(3) do |posts| %>
  <% posts.each_with_index do |post, index| %>
    <div class="grid-<%= index + 1%>">
      <%= post.title %>
    </div>
  <% end %>
<% end %>

Posted in Jekyll as a support page?

If you compiled them so they output to public/support that would probably do the trick.

Posted in Getting back into Rails

The biggest changes in Rails are around Webpacker + Stimulus + ActionCable, so any of the videos that cover those topics would be a great place to start. 👍

Posted in Installation

If you need that, sure. I would probably try to keep all my apps running the same Node version though and just update it on the server periodically. That way you can make sure none of your apps get neglected on an insecure Node version and keeps things simpler. That's what I'm currently doing.

Posted in Acts_As_Tentant User have access to many tenants

@Tim Dowling In Jumpstart Pro, tenant is stored depending on how you want your app to work. We can use the session, the URL (like basecamp does), the subdomain, or the actual domain. Session is the default since it's the least invasive and simplest option.

Posted in Soft Delete with Paranoia Discussion

I still use it for most things, but there's also https://github.com/jhawthorn/discard

I got some time yesterday to update the library to automatically handle it as long as there's an ID on the tab. 👍

Posted in How to use Action Mailbox in Rails 6 Discussion

Emails have a message-id and in-reply-to header that you can use for tracking that info. I haven't played with it too much, but you'd probably want to save the message-id after an email is sent, and always make sure you include the in-reply-to as necessary.

@Mvondo, sounds like you forgot to add the capistrano-rails gem to your Gemfile.

That is easy enough! Protip is you can use the index method to find the index integer quickly and simplify this a bit:

irb(main):001:0> ["a", "b", "c"].index("a")
=> 0
irb(main):002:0> ["a", "b", "c"].index("c")
=> 2

So like:

def index_based_on_controller(controller)
  ["user_books", "user_books/want_to_read", "user_books/reading_now", ... etc ].index(controller)
end

If you set the data index attribute in the HTML when you render the page, that tab will be pre-selected. You'll just have to use a helper in Rails to check the anchor and see if it matches a tab to set the index.

We need to add some code to the code so it can automatically select the index for you when the page loads with a matching anchor still. 👍

I would just put a before_action on all the controllers that directs away if they aren't subscribed. Nice and simple.

Yeah, that's the main argument for using cookies. They can't be stolen easily because the browser secure them. It also introduces some annoyances building services with iframes and things. CORS is confusing, but may be able to solve your problems with cookies. JWTs have to be stored in LocalStorage and that means they aren't really stored securely if Javascript can access it.

There's nothing builtin to Rails to read or write option1 or option2 directly.

You can assign a hash to something_here and it will work just fine though so you can write your own helper method to read from that, just have to assign the hash though when you want to change it.

Posted in New Design!

Tailwind has made design changes SO easy. It's definitely been my favorite tool I've started using in the last year.