TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Hash#path_exists? method [ruby]

1 pointsby mrTheabout 12 years ago
Hi guys, i just write this method: http://gist.github.com/mrThe/5143746<p>Why? Becouse i can write BaseController method like this:<p><pre><code> def check_params!(path, exception = "Not enough params") raise exception unless params.deep_symbolize_keys.path_exists?(path) end </code></pre> And use it like this in needed controller action:<p><pre><code> check_params!({:user =&#62; [:email]}, "No email") </code></pre> instead of<p><pre><code> raise "No email" unless params[:user] &#38;&#38; params[:user][:email] </code></pre> What do you think about this? Is it good idea?<p>/related to Ruby On Rails, i write some RESTful api app and every time will check input params.

no comments

no comments