Skip to content

Instantly share code, notes, and snippets.

@leikind
Created May 23, 2011
Embed
What would you like to do?
traversing params
class HashWithIndifferentAccess
def get_to(*keys)
subhash = self
keys.each do |k|
subhash = subhash.try(:[], k)
return nil if subhash.nil?
end
if block_given? && subhash.any?
yield subhash
else
subhash
end
end
end
def update
p params.get_to(:ad, :ad_club_availability_attributes, :foo)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment