Skip to content

Instantly share code, notes, and snippets.

Kyle Prifogle kyprifog

Block or report user

Report or block kyprifog

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kyprifog
kyprifog / create_user.rb
Created Mar 4, 2016
Strong Parameters in Service Object
View create_user.rb
class CreateUser
def initialize(params)
@params = user_params(params)
@user = User.new(@params)
end
def perform
ActiveRecord::Base.transaction do
# do stuff
@kyprifog
kyprifog / pluck_all.rb
Created Oct 6, 2015
Active Record Pluck All
View pluck_all.rb
# pluck_all.rb
module ActiveRecord
class Relation
def pluck_all(*args)
args.map! do |column_name|
if column_name.is_a?(Symbol) && column_names.include?(column_name.to_s)
"#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column_name)}"
else
column_name.to_s
end
You can’t perform that action at this time.