Activity
Posted in User logoff/clear session
Hey Dainius,
That looks like it would work fine to me. What's happening? You're still logged in after it redirects you?
You're going to want to change that to a DELETE request though, otherwise people can do semi-malicious things and log you out from any website just by making your browser load that URL.
Jesus, yup all the concepts are still the same for Rails 6.
The only change is that Javascript is now primarily written in the app/javascript folder using Webpacker instead of the asset pipeline in app/assets/javascripts. Still works about the same, but has a lot of new features.
Stylesheets still go in app/assets/stylesheets, same as before.
Filled this out a while back. Thanks for putting this together. Always love seeing the results here. 👍
This is awesome Martin!
Rails calls them "routes", not links. That's what you'll want to search for and read up on. 👍
Posted in How to build a wizard
I like that idea. Honestly for most wizard things, I have used Wicked (https://github.com/zombocom/wicked) just about every time. It controls the steps for you and stores them on the model so it remembers the location and everything.
I'd probably still recommend Wicked, but it'd be great to do a basic walkthrough of how you'd implement this from scratch too.
I would pass in the search params into the employee show URL so you can have a link back to the search results that includes the same params.
Ah sorry I was confused. I was thinking of the "active" state of a link / tab / etc.
He's referring to active
like the &:active {
css selector.
You either need to define it or just have it add the classes you want to the list. "Active" means very different things depending on your UI design.
I either do it inline or in a helper.
Here's an inline example:
<%= link_to "Account", account_path, class: ["blue", ("active" if request.path == account_path)]
Hey Fahad,
Try using this gem to add ActiveStorage support instead: https://github.com/Dreamersoul/administrate-field-active_storage
Posted in Iterating using css grid
Yeah, you want to pass it in as a local variable like so:
<%= render 'gyms/card', locals: { gym: gym, index: index } %>
Partials need locals passed in so it can assign those variables and use them the same way as the parent template was.
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. 👍