Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
曹小华
@cxh116
高级会员
第 17 位会员 / 2011-10-31

长沙
55 篇帖子 / 541 条回帖
19 关注者
0 正在关注
31 收藏
GitHub Public Repos
  • leek 60

    跨交易所套利框架.基于 Python asyncio, CCXT, WebSocket.

  • alipay_red_helper 37

    支付宝抓红包助手

  • ccxtws 35

    基于 CCXT 和 WebSocket 对接交易深度数据

  • mow 29

    运行 Leek 项目的套利程序

  • generalstorefrontend 8

  • mangege.github.io 7

    我的博客,基于Jekyll

  • kimi 7

    一个基于ansible自动配置linux服务器项目

  • generalstorebackend 6

  • discourse_shell 5

    不使用 Docker 部署 Discourse

  • lede-source 4

    LEDE with various device support

More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • Rails 中临时把一个 model 的错误消息删除该怎么做? at 2012年11月09日
    class Errors
      include Enumerable
      attr_reader :errors
    
      delegate :empty?, :to => :errors
    
      def initialize(base) # :nodoc:
        @base, @errors = base, {}
      end
      ....
     end
    

    从 2.3 的源码可以看出,your_model.errors.errors 将会返回一个 Hash,然后用 delete 方法删除应该就可以了。理论上是这样的,你要可以试试 your_model.errors.errors.delete(key)

  • Rails 中临时把一个 model 的错误消息删除该怎么做? at 2012年11月09日

    your_model.errors.delete(key) http://apidock.com/rails/v3.2.8/ActiveModel/Errors/delete

    key 一般是 field name,可以把 errors 打印看看

  • 在 js 中嵌入 ruby 代码 at 2012年11月07日

    貌似你是需要 js 里引入应用配置,也许这个对你有用 http://ruby-china.org/topics/6167

  • 这种类型的"Missing template "大家怎么处理 at 2012年11月06日

    #3 楼 @zzhattzzh 能给下简单代码吗? 看了下 Rails Guides,有些地方不太好处理,例如: resources :posts,只有 index 需要 atom 和 rss 格式,其它的只需要支持 html 格式就行了

    如果在 action 里把 render 写在 respond_to 里可以解决,返回的是 406 状态,但这样就需要把所有的 render 都包含在 respond_to 里 太麻烦了

  • 求推荐能记账的好网站 at 2012年11月06日

    随手记,还有手机版 http://www.feidee.com/

  • 多个 rails 版本如何管理和切换 at 2012年11月04日

    用 rvm 的 gemset https://rvm.io/gemsets/basics/

  • debian 如何关掉喇叭声音?(解决) at 2012年11月03日

    个人比较推荐xset b off http://www.debian-administration.org/articles/110 https://wiki.archlinux.org/index.php/Disable_PC_Speaker_Beep

  • 以"京东充值漏洞"聊聊测试驱动开发 at 2012年11月02日

    感觉这个不是简单的测试驱动就能解决的问题 整体的架构,流程感觉很重要

  • 用 haml 的一种痛苦场景 at 2012年11月01日

    #8 楼 @ruby_sky 那有这么好的事了,男的。这个只是帮别人忙,自己加班抽时间。其它的项目太忙了,上班的时候抽不开

    经过这次,觉得 coffeescript,scss,haml 之类的还是要慎用

  • 用 haml 的一种痛苦场景 at 2012年11月01日

    #3 楼 @richard020389 #4 楼 @lmorenbit #5 楼 @ericguo 这个是用 nanoc 的文档站点,需要改的是 layout, 最终还是把 layout 从 haml 改成 erb 谢谢各位了

  • 用 haml 的一种痛苦场景 at 2012年11月01日

    #1 楼 @lgn21st 改不下去了 必须叫美工一起和我一起改 haml 的空格对齐修改时根本就不知道到底是缩进多少个

  • 请教一个问题, 如何将 `方法参数的输入' 反射到方法内? at 2012年11月01日

    用 proc 加第三方包好像可以实现 http://stackoverflow.com/questions/4811501/how-to-extract-the-code-from-a-proc-object

  • 我写的论坛软件现已开源:Rabel - PB2 on Rails at 2012年10月31日

    支持,希望国内 Ruby 的开源程序能追上 PHP,但开源方式不要像那些 PHP 程序

  • 有没有人遇见 spreadsheet 插件读取数据问题 at 2012年10月30日

    用row.at(3)试试 这里官方的描述 < Whenever a Cell’s Format describes a Date or Time, Spreadsheet will give you the decoded Date or DateTime value. Should you need to access the underlying Float, you may do the following: < < row.at(3) http://spreadsheet.rubyforge.org/GUIDE_txt.html

  • 关于 ubuntu12.04 下 wiki 中安装 rails 方法的探讨 at 2012年10月29日

    这个估计是写给新手的 ,把用户权限给加进去,很容易凌乱的

    个人的思路,可以一起探讨一下 rvm 以单用户安装,或以 root 安装时把普通用户添加到 rvm 组 rails 应用创建单用户,再用passenger_user指定切换应用用户,public 目录 nginx 的 www-data 用户估计得有读权限,具体操作请看 passenger 手册 http://www.modrails.com/documentation/Users%20guide%20Nginx.html#user_switching

    没有实现过,有成功部署的经验可以写博文分享下 个人用的是 nginx+thin,想分享,但一直没有重新部署需求。写这个得边部署边写才行.而且还得有干净的环境

  • 貌似 github 已经被墙了 at 2012年10月27日

    #4 楼 @Rei 貌似已经好了 铁通的 DNS 刚出了点问题 有些域名不能正常解析出 ip

  • 貌似 github 已经被墙了 at 2012年10月27日

    #1 楼 @Magic 不知道我 ping 出来的 ip 是不是对的

    ping github.com
    PING github.com (207.97.227.239) 56(84) bytes of data.
    
  • aop 功能似乎不如 spring at 2012年10月26日

    #7 楼 @chenge 嗯 是一个什么功能,需要这样加 callback

  • aop 功能似乎不如 spring at 2012年10月26日

    不知道是一个什么样的场景,自定义 callback 都觉得不好用?

  • 同一文件流只能遍历一次? at 2012年10月25日

    对 C 底层不是很了解,只知道有 rewind 方法手动复位 http://apidock.com/ruby/v1_9_3_125/IO/rewind

  • 大家是怎么管理你们的 js 的? at 2012年10月25日

    想办法判断出页面 比如在topic#show页面里写上

    <script type="text/javascript" language="javascript" charset="utf-8">
    //<![CDATA[
      window.page_name = "topic_show";
    //]]>
    </script>
    

    在 JS 文件里的$.ready 里根据 window.page_name 判断是什么页面,再运行你需要运行的 JS

    在页面里单独调用 JS 方法时,记得用$.ready JS 方法调用最好在 include script 标签后面

  • 请教一个 nginx 配置新手问题 at 2012年10月25日

    也许还要重写redirect_to方法,参数默认加上:host http://apidock.com/rails/ActionController/Redirecting/redirect_to

  • 请教一个 nginx 配置新手问题 at 2012年10月25日

    #15 楼 @cdredfox 这个和 IP 一样,你需要自定义的个 header,把 host 传过来 再重写 default_url_options 方法 http://stackoverflow.com/questions/2660172/how-do-i-set-default-host-for-url-helpers-in-rails

  • 请教一个 nginx 配置新手问题 at 2012年10月24日

    #13 楼 @cdredfox 用instance_variable_set方法 request.instance_variable_set('@remote_ip', 'value') http://apidock.com/ruby/Object/instance_variable_set

  • 请教一个 nginx 配置新手问题 at 2012年10月24日

    #9 楼 @cdredfox 应该是服务器做了检测 你可以自己写一个 rack middleware,修改 request header

    或直接修改 request.remote_ip 方法,因为看了一下 devise 调用的是request.remote_ip http://apidock.com/rails/ActionDispatch/Request/remote_ip 感觉只要在 devise 调用 remote_ip 方法前把 request 对象的@remote_ip变量改了就行了

  • 请教一个 nginx 配置新手问题 at 2012年10月24日

    #6 楼 @cdredfox 拿访问者 ip 反向代理如果不加 X-Real-IP 和 X-Forwarded-For,到时request.remote_ip拿到的 ip 总是反向代理服务器的

    你改成自定义的名称后可以这样改 request.headers["header name"]

  • 请教一个 nginx 配置新手问题 at 2012年10月24日

    #4 楼 @cdredfox 它是没有办法禁用掉反向代理的,因为它其实就是一个普通请求 你先把proxy_set_header去掉,尽量把 http request header 改成用abc.demo.com一样 之后如果需要传 IP,把X-Real-IP改成一个非标准名称

  • 请教一个 nginx 配置新手问题 at 2012年10月24日

    #2 楼 @cdredfox abc.com这个域名你已经改了 IP 指向?可以先在本地通过修改 hosts 来测试看看

    这是我的反向代理配置,和你的差不多,你看一下你的 nginx error.log

    proxy_temp_path   /tmp/proxy_temp_dir 1 2;
    proxy_cache_path /tmp/proxy_cache_dir levels=1:2 keys_zone=nytimes:1m inactive=10m max_size=10m;
    # the server directive is nginx's virtual host directive.
    server {
    # port to listen on. Can also be set to an IP:PORT
            listen 80;
    
    # Set the max size for file uploads to 50Mb
            client_max_body_size 1M;
    
    # sets the domain[s] that this vhost server requests for
    # server_name www.[engineyard].com [engineyard].com;
            server_name cn_nytimes_feed.lvcake.com;
    
    # doc root
            root /usr/share/nginx/html;
    
    # vhost specific access log
            access_log  /home/outman/log/cnnytimesfeed_access.log  main;
    
    
            location / {
    # needed to forward user's IP address to rails
    #      proxy_set_header  X-Real-IP  $remote_addr;
    
    # needed for HTTPS
    #      proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    #      proxy_set_header Host $http_host;
                    proxy_redirect off;
    #      proxy_max_temp_file_size 0;
    
    
                    proxy_pass http://cnnytimesfeed-mangege.rhcloud.com;
    
                    proxy_connect_timeout      90;
                    proxy_send_timeout         90;
                    proxy_read_timeout         90;
    
                    proxy_cache nytimes; 
                    proxy_cache_valid 200 302 30m; 
                    proxy_cache_valid 301 1d; 
                    proxy_cache_valid any 30m; 
    
                    proxy_buffer_size          4k;
                    proxy_buffers              4 32k;
                    proxy_busy_buffers_size    64k;
                    proxy_temp_file_write_size 64k;
            }
    
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                    root   /usr/share/nginx/html;
            }
    }
    
    
    
  • 请教一个 nginx 配置新手问题 at 2012年10月24日

    proxy_pass http://abc.demo.com/; 去掉"/"试试 proxy_pass http://abc.demo.com;

  • 宿舍断电后,linux 重启后,很多文件消失了 at 2012年10月24日

    不重要的话,可以尝试用 fsck 命令修复看看,重要的话就硬盘现在不要读写了,等高手解答

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