Skip to content

Instantly share code, notes, and snippets.

View bonniesimon's full-sized avatar
Confused , Frustrated and Caffeinated.☕

Bonnie Simon bonniesimon

Confused , Frustrated and Caffeinated.☕
View GitHub Profile
@bonniesimon
bonniesimon / check_presense_of_helper_methods.rb
Last active July 24, 2024 21:29
Using view_helper methods directly in a view_component file throws an error. We have to use helper.method_name to access the view helper method. So first we need to find helper methods that are used in the view_component.
# Script to get all function names from all helpers and check their presence in a specific file
def get_all_helper_functions
all_helper_functions = []
Dir[Rails.root.join("app", "helpers", "**", "*_helper.rb")].each do |helper_file|
relative_path = Pathname.new(helper_file).relative_path_from(Rails.root.join("app", "helpers")).to_s
helper_module_name = relative_path.chomp(".rb").camelize
begin
@bonniesimon
bonniesimon / Preventing push to master.md
Last active September 25, 2022 08:46
Added the necessary hooks to prevent push to master.

Create a file .husky/helpers/prevent_pushing_to_master.sh and add the following contents:

  #!/bin/sh
  
  prevent_pushing_to_master() {
    current_branch=`git symbolic-ref HEAD`
    current_origin=`git remote`
    if [ current_origin = "origin" -o "$current_branch" = "refs/heads/master" -o "$current_branch" = "refs/heads/master" ]
    then
    cat <<EOT