Skip to content

Instantly share code, notes, and snippets.

@leikind
Created May 23, 2011 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leikind/986735 to your computer and use it in GitHub Desktop.
Save leikind/986735 to your computer and use it in GitHub Desktop.
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