Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jho406 committed Dec 14, 2024
1 parent 703cc14 commit 0c6daf5
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,14 @@ def copy_js_files
def add_member_methods
inject_into_file "app/models/application_record.rb", after: "class ApplicationRecord < ActiveRecord::Base\n" do
<<-RUBY
# This enables digging by index when used with props_template
# see https://thoughtbot.github.io/superglue/digging/#index-based-selection
def self.member_at(index)
offset(index).limit(1).first
end
# This enables digging by attribute when used with props_template
# see https://thoughtbot.github.io/superglue/digging/#attribute-based-selection
def self.member_by(attr, value)
find_by(Hash[attr, value])
end
Expand Down

0 comments on commit 0c6daf5

Please sign in to comment.