Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
wan
@lelewan
Member
NO. 21027 / 2015-09-10

0 Topics / 5 Replies
0 Followers
0 Following
1 Favorites
GitHub Public Repos
  • lelewan.github.com 0

    my page

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 送几本《Ruby on Rails 教程 (第 4 版)》纸质书 at November 01, 2017

    支持,买了好几本你的电子书。

  • 准备着手翻译出版《Rebuilding Rails》,有人愿意买吗? at November 18, 2015

    会买的

  • Grape 的 JSON 参数验证,以及 nested params 问题 at September 11, 2015

    @seaify

    desc "增加资源"
    params do
      requires :field, type: Hash, allow_blank: false do
        requires : field1, type: String, allow_blank: false
        requires : field2, type: String, allow_blank: false
      end
    end
    post do
      result = REDIS.hgetall:"#{params[:field][:field1]}"
      if result.blank? 
          REDIS.hset:"#{params[:field][:field1]}",FIELD2,"#{params[:field][:field2]}"  
      else
        {:error => "#{params[:field][:field1]}已经存在" }
      end
    end
    

    rest-client 安装后执行 restclient。终端请求格式:

    RestClient.post "http://localhost:9000/api/v1/demo", { 'field' => {'field1' => 'X12345','field2' => 'iii'} }.to_json, :content_type => :json, :accept => :json
    
  • Grape 的 JSON 参数验证,以及 nested params 问题 at September 11, 2015

    @seaify 我用 curl 请求 hash 格式通不过 requires 校验,后来改用 rest_client 就可以了,应该是我 curl 格式搞错了,谢谢回复。

  • Grape 的 JSON 参数验证,以及 nested params 问题 at September 10, 2015

    请问你的问题解决了没有?我也遇到同样问题。

关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English