Ask HN: Hash#path_exists? method [ruby]1 points·by mrThe·13 lat temu·0 commentsHi guys, i just write this method: http://gist.github.com/mrThe/5143746Why? Becouse i can write BaseController method like this: def check_params!(path, exception = "Not enough params") raise exception unless params.deep_symbolize_keys.path_exists?(path) end And use it like this in needed controller action: check_params!({:user => [:email]}, "No email") instead of raise "No email" unless params[:user] && params[:user][:email] What do you think about this? Is it good idea?/related to Ruby On Rails, i write some RESTful api app and every time will check input params.0 commentsPost comment—
Why? Becouse i can write BaseController method like this:
And use it like this in needed controller action:
instead of
What do you think about this? Is it good idea?
/related to Ruby On Rails, i write some RESTful api app and every time will check input params.