This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# Alias as follows: | |
# | |
# alias rg="~/scripts/rails_g_and_open_in_sublime.rb" | |
# | |
# Then use like this: | |
# | |
# $ rg model Post | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Changes ["Fizz", "Buzz"] into ["FizzBuzz"] | |
def collapse(hash) | |
hash.each do |key, value| | |
hash[key] = [value.join()] | |
end | |
end | |
100.times.each do |i| | |
result = Hash.new{[]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fixtures::Concern::CircularClass | |
A = "a" | |
include Fixtures::Concern::CircularConcern | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Not fully tested, use at own risk! | |
module ActiveModel | |
module MassAssignmentSecurity | |
# Original source: https://github.com/rails/protected_attributes/blob/0421e825911b05a77c6521171b43070c9e6c4b35/lib/active_model/mass_assignment_security.rb#L350 | |
def sanitize_for_mass_assignment(attributes, role = nil) #:nodoc: | |
if attributes.respond_to?(:permitted?) && _uses_mass_assignment_security | |
_mass_assignment_sanitizer.sanitize(self.class, attributes, mass_assignment_authorizer(role)) | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveModel | |
module MassAssignmentSecurity | |
# Original source: https://github.com/rails/protected_attributes/blob/0421e825911b05a77c6521171b43070c9e6c4b35/lib/active_model/mass_assignment_security.rb#L350 | |
def sanitize_for_mass_assignment(attributes, role = nil) #:nodoc: | |
if attributes.respond_to?(:permitted?) && _uses_mass_assignment_security | |
_mass_assignment_sanitizer.sanitize(self.class, attributes, mass_assignment_authorizer(role)) | |
else | |
sanitize_forbidden_attributes(attributes) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "spec_helper" | |
RSpec.describe MyClass do | |
describe "#some_private_method" do | |
expose_method MyClass, :some_private_method | |
it "works" do | |
MyClass.new.some_private_method | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The new `travel_to` does not allow nested calls, and instead throws the following error | |
# in your face whenever you try to use it: | |
# | |
# Calling `travel_to` with a block, when we have previously already made a call to `travel_to`, can lead to confusing time stubbing. | |
# | |
# Using this module to override `travel_to` will solve that issue. | |
# | |
# Note: not guaranteed to work perfectly | |
# | |
module BetterTravelTo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from: https://news.ycombinator.com/item?id=26371997 | |
inherit_from: | |
- https://raw.githubusercontent.com/testdouble/standard/master/config/base.yml | |
Style/TrailingCommaInArrayLiteral: | |
Enabled: true | |
EnforcedStyleForMultiline: consistent_comma | |
Style/TrailingCommaInHashLiteral: | |
Enabled: true |
OlderNewer