Brian Gilbank

Joined

8,640 Experience
58 Lessons Completed
3 Questions Solved

Activity

Posted in How to use Hotwire in Rails Discussion

I can't get any of my delete links to work, has this happened to anyone else?

Posted in Rails for Beginners Part 17: Login Form Discussion

Yes I know. I meant be able to login with either at the same time, similar to how you do it with Devise. https://github.com/heartcombo/devise/wiki/How-To:-Allow-users-to-sign-in-using-their-username-or-email-address

Posted in Rails for Beginners Part 17: Login Form Discussion

It would be great to show how to do login with both username and email as well.

Posted in How to use Devise with Hotwire & Turbo.js Discussion

Hey Chris - If we are still using Webpacker, we just need to change data-turbolinks-track to data-turbo-track in our layout files? In your episode repo, you still have it as turbolinks.

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbo-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbo-track': 'reload' %>

<%= turbo_include_tags %>

<%= stimulus_include_tags %> if we want to use stimulus in webpacker?

Posted in How do I search Action Text with Ransack?

Thanks, I will play around with it and see what I can figure out.

Posted in How do I search Action Text with Ransack?

Thank you! I am now getting duplicates in my searches though. Did that happen to you?

Posted in How to Add Pagination with Pagy Discussion

If we are counting records, ie. <%= index + 1%> how can we keep the count going when we we navigate to the next page? Currently my next page starts at 1 again.

Posted in Skipping Devise Confirmation for Stripe Signup

Hi Chris - How could I skip the Devise confirmation if a user is signing up to pay with Stripe?

I am following this video on your stripe course: https://courses.gorails.com/courses/payments-with-rails-master-class/152586-subscriptions-with-stripe-billing/451458-3-4-new-subscription-form

I was hoping I could do something like below.

class Users::RegistrationsController < Devise::RegistrationsController
invisible_captcha only: [:create], honeypot: :telephone, scope: :user, on_spam: :return_succeded

def create
super
if @user.persisted?
UserMailer.newuser_email(@user).deliver
end
if @user.persisted? && current_user.subscribed?
@user.skip_confirmation!
@user.confirm
end
end

end

Thanks
Brian

Posted in Action Text Colours & More Heading Options

Hey Chris - Is it possible to add a colour picker to action text, i.e. select some text and change its colour? Seems like a basic thing that should be included. It would be great if there were more heading options too. Maybe it will get an update because of hey.com?

Posted in Iterating using css grid

I had to add partial and it worked. Cheers,

<%= render partial: 'card', locals: { gym: gym, index: index } %>

Posted in Iterating using css grid

Hmm, still throwing the same error.

Posted in Iterating using css grid

I had it originally in a partial, but it was throwing an error for undefined local variable or method for gym.

<% if gym.image.present? %>

Posted in Iterating using css grid

Omg! I will get this one day. Thanks again.

Posted in Iterating using css grid

it's not stopping at 3 when it counts, eg

def index
  @q = Gym.ransack(params[:q]) 
  @gyms = @q.result.includes(:province).page(params[:page]).order("created_at DESC").paginate(:page => params[:page], :per_page => 18)
end

Posted in Iterating using css grid

Hey Chris - Just a follow up on this question. I am seeing a bunch of duplicate entries: https://gympass.ca/fitness-facilities for some reason?

<div class="clubs__index">
      <% @gyms.each_slice(3) do |gyms| %>
       <% @gyms.each_with_index do |gym, index| %>
        <div class="clubs__index--<%= index + 1 %>">
         <%#= render 'gyms/card' %>
         <div class="card">
          <% if gym.image.present? %>
            <%= image_tag gym.image.url, class: 'card__image', alt: gym.gym_name, size: "700X500"  %>
          <% else %>
            <%= image_tag 'https://ficdn-files.ca/images/gympass/logo/default_club_image_index.jpg', class: 'card__image', loading: "lazy" %>
          <% end %>
          <h3 class="card__title"><%= gym.gym_name %></h3>
            <h5 class="card__address">
            <%= gym.gym_address.titleize %><br> 
            <%= gym.gym_city.titleize %> / <%= gym.province.name if gym.province %><br>
            <%= gym.gym_postal.insert(3, ' ').upcase %>
            </h5> 
            <p class="card__details">
            <span class="card__details--bold"><%= t("gyms_index.telephone") %></span>
            <%= number_to_phone(gym.gym_telephone, area_code: true ) %><br>
            <% if gym.ext.present? %>
              <span class="card__details--bold"><%= t("gyms_index.ext") %></span>
              <%= gym.ext  %><br>
              <% end  %>
            <% if gym.gym_email.present? %>
              <span class="card__details--bold"><%= t("gyms_index.email") %></span>
              <%= gym.gym_email.downcase %> 
            <% end %>
          </p>
          <p class="card__url">
            <% if gym.gym_website.present? %>
            <%= link_to url_for(gym.gym_website), target: '_blank' do  %>
            <%= truncate(gym.gym_website.downcase.try(:remove, /.*\/\//), :escape => false, :length => 44)  %>
            <% end %>
          <% end %>
          </p>
          <ul class="card__social">
            <% if gym.gym_facebook.present? %>
            <li class="card__social--items">
              <%= link_to gym.gym_facebook, target: '_blank' do %>
              <i class="card__social--icons fab fa-facebook-f"></i>
              <% end %>
            </li>
            <% end %>
            <% if gym.gym_twitter.present? %>
            <li class="card__social--items">
              <%= link_to gym.gym_twitter , target: '_blank' do %>
              <i class="card__social--icons fab fa-twitter"></i>
              <% end %>
            </li>
            <% end %>
            <% if gym.gym_instagram.present? %>
            <li class="card__social--items">
              <%= link_to gym.gym_instagram, target: '_blank' do %>
              <i class="card__social--icons fab fa-instagram"></i>
              <% end %>
            </li>
            <% end %>
            <% if gym.gym_youtube.present? %>
            <li class="card__social--items">
              <%= link_to gym.gym_youtube, target: '_blank' do %>
              <i class="card__social--icons fab fa-youtube"></i>
              <% end %>
            </li>
            <% end %>
          </ul>
          <% if logged_in? %>
          <ul class="card__admin">
            <li class="card__admin--items">
              <%= link_to 'View', gym, class: "link-padding" %>
            </li>
            <li class="card__admin--items">
              <%= link_to 'Edit', edit_gym_path(gym), class: "link-padding" %>
            </li>
            <li class="card__admin--items">
              <%= link_to 'Destroy', gym, method: :delete, data: { confirm: 'Are you sure?' }, class: "link-padding" %>
            </li>
          </ul>
          <% end %>                                       
        </div> <%# card %>

        </div>
       <% end %> <%# do block end %> 
      <% end %>

    </div>  <%# clubs index %>

Posted in Iterating using css grid

Awesome you saved me! It probably would have taken me a week to figure that out. Thank you.

I wanted to rebuild a site without using a CSS framework. But I will try out Tailwind on my next project.

Posted in Iterating using css grid

Hi Chris - I am using CSS grid for a three-column blog layout. Unfortunately, when I run the do bock it creates three instances of the same post. I guess this is to be expected.

Not sure how to get around this issue with CSS grid. Wondering if you might know of a fix?

I put a basic example below.

.someclass {
 display: grid;
 grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

Index page

<% @posts.each do |post| %>

# grid one
<div class="grid-1">
 <%= post.title %>
</div>

# grid two
<div class="grid-2">
 <%= post.title %>
</div>

# grid three
<div class="grid-3">
 <%= post.title %>
</div>

<% end %>

Posted in Tabs with Stimulus

Hahah!

Posted in Tabs with Stimulus

Thanks for the quick response, Chris. I switched computers and forgot that I didn't have any pages created on my desktop database. Embarrassing mistake lol.

Posted in Tabs with Stimulus

Oh never mind I am dumb. Figured it out.

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.