TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Hash#path_exists? method [ruby]

1 点作者 mrThe大约 12 年前
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.

暂无评论

暂无评论