Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
Rei
@Rei
Admin
NO. 1 / 2011-10-28

[email protected]
深圳
182 Topics / 9132 Replies
727 Followers
0 Following
11 Favorites
中下水平 Rails 程序员
Reward
GitHub Public Repos
  • writings 940

    [Closed] Source code of writings.io

  • alipay 732

    Unofficial alipay ruby gem

  • code_campo 291

    [Closed] Source code of http://codecampo.com

  • asciidoctor-pdf-cjk-ka... 101

    **no longer maintained**

  • asciidoctor-htmlbook 31

    Asciidoctor HTMLBook is an Asciidoctor backend for converting AsciiDoc documents to HTMLBook docu...

  • material-ui 17

  • rich-text-editor 12

  • htmlrenderer 12

  • rails-chatgpt-demo 8

  • rails-app 7

    A Rails project template lets me start new projects quickly.

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 有没有比较好的文档分享开源程序? at December 01, 2011

    pdf.js

    pdf.js is an HTML5 technology experiment that explores building a faithful and efficient Portable Document Format (PDF) renderer without native code assistance.

    https://github.com/mozilla/pdf.js

    demo http://mozilla.github.com/pdf.js/web/viewer.html

    悲剧,我这里字体挤成一堆

  • 用 highlight_js-rails 高亮代码 at December 01, 2011

    #1 楼 @huacnlee 有一堆可选的自动检测规则,也可以指定语言 http://softwaremaniacs.org/soft/highlight/en/description/

    自动检测有时会错误,比如 python 和 ruby 就经常认错,所以我只加载了 ruby 没有 python

    demo 和 styles http://softwaremaniacs.org/media/soft/highlight/test.html

  • 现在支持代码区域语法高亮了 at December 01, 2011

    那撒花效果不错

  • 现在支持代码区域语法高亮了 at December 01, 2011

    现在兼容的模式有点杂,觉得基于 markdown 出发比较好,遗留的 img 语法跑脚本处理一下

  • belongs_to,has_one,has_many,has_and_belongs_to_many 求讲解 at November 30, 2011

    http://guides.rubyonrails.org/association_basics.html 看这里

  • 坑爹啊!Rails 里面发现 String.gsub! 方法的 Bug at November 30, 2011

    这……不就把 gusb! 废掉了

  • ruby-china 安装遇到问题,请高手解答! at November 30, 2011

    用 ruby 1.9.2 以上版本

  • 可以从 Ruby China 的 Mongo 里 Replicate 数据到本地吗? at November 30, 2011

    #3 楼 @lainuo 取决于要测试什么层面,如果是测试逻辑功能的话自带的 Test::Unit 就行了。

  • 可以从 Ruby China 的 Mongo 里 Replicate 数据到本地吗? at November 30, 2011

    用户邮箱是不能随便导出的。我建议用 factroy girl + 自动测试

  • 问一下那种解释行语言性能最高? at November 30, 2011

    lua 好像口碑不错(我没搞过

  • 由于 Ruby-china.org 得 DNS 配置变更,可能会给您造成一些访问上得不便,请谅解 at November 29, 2011

    吾皇万岁万岁万万岁

  • 测试网站是否用 RoR 做的 at November 29, 2011

    我自首,跑去测试了

  • 中央政府采购网竟然是用 rails 开发的 at November 29, 2011

    #11 楼 @hooopo 奥,原来我也是奥特曼

  • 中央政府采购网竟然是用 rails 开发的 at November 29, 2011

    #5 楼 @hooopo 跑题的图片不好

    #8 楼 @sunfmin Cool~

  • 大家有在用 “记事本” 这个功能么?好奇问问 at November 29, 2011

    我用 Google task.

  • 如何在 controller 为 model 中的实例动态地创建 model? at November 29, 2011

    #16 楼 @huacnlee 哈哈,晚安

  • 如何在 controller 为 model 中的实例动态地创建 model? at November 29, 2011

    #3 楼 @hooopo

  • 如何在 controller 为 model 中的实例动态地创建 model? at November 29, 2011
    class Servey
      include Mongoid::Document
      embed_many :columns
      has_many :answers
    
      def check_validate(answer)
        columns.each do |column|
          column.errors.add(column.name, "some message") unless column.check_validate?(answer[column.name])
        end
      end
    end
    
    class Column
      field :name
      embed_in :servey
    
      def check_validate?(value)
        raise "Not implement yet."
      end
    end
    
    class StringColumn < Column
      def check_validate?(value)
        #do nothing
      end
    end
    
    class RangeColumn < Column
      field :max, :type => Integer
      field :min, :type => Integer
    
      def check_validate?(value)
        value <= max && value >= min
      end
    end
    
    class CheckColumn < Column
      field :values, :type => Array
    
      def check_validate?(value)
        values.include?(value)
      end
    end
    
    class Answer
      include Mongoid::Document
      belongs_to :servey
      attr_protected :servey_id
    
      validates :servey_validate
      def servey_validate
        servey.check_validate(self)
      end
    end
    
    # controller
    
    def create
      @answer = @survey.answers.new params[:answer] # DYNAMIC FIELDS http://mongoid.org/docs/documents/dynamic.html
      if @answer.save
        #...
      else
        #...
      end
    end
    
  • 如何在 controller 为 model 中的实例动态地创建 model? at November 29, 2011

    你要做的可能是设计 validation 这块,创建问卷的时候保存校验信息,然后储存答卷的时候调用校验。

    如果没有校验,mongodb 尽可以随意储存不同的 field 的文档。

    > db.answers.insert({name: 'Rei', age: 24})
    > db.answers.insert({weather: 'cold', temperature: [-1, 4]})
    > db.answers.find();
    { "_id" : ObjectId("4ed3b3ad665202a0ac36e109"), "name" : "Rei", "age" : 24 }
    { "_id" : ObjectId("4ed3b3ea665202a0ac36e10a"), "weather" : "cold", "temperature" : [ -1, 4 ] }
    
  • 如何在 controller 为 model 中的实例动态地创建 model? at November 29, 2011

    不要想类,想文档。

    用户提交的是文档,数据库储存的是文档,到底需要类做什么呢?

  • 如何在 controller 为 model 中的实例动态地创建 model? at November 28, 2011

    你的需求是如何保存问卷格式和问卷结果,而不是如何动态生成类。

  • 如何在 controller 为 model 中的实例动态地创建 model? at November 28, 2011

    你还没明白不应该这样弄么

    what_ever = Class.new # 生成一个类
    
  • rails new test_app 时出现以下错误!求解啊!!!! at November 28, 2011

    #15 楼 @huacnlee 话说能不能自动生成 tmp 的?或者预先创建放个 .gitkeep 进去

  • rails new test_app 时出现以下错误!求解啊!!!! at November 28, 2011

    自己新建一个 tmp/pids 文件夹,然后执行,不用 root

  • rails new test_app 时出现以下错误!求解啊!!!! at November 28, 2011

    #8 楼 @hangzai

    ls -ld /tmp/pids/
    ls -l /tmp/pids/unicorn.pid
    

    执行看看结果

  • rails new test_app 时出现以下错误!求解啊!!!! at November 28, 2011

    #6 楼 @hangzai 重复@只会让人厌烦

    directory for pid=/home/deployer/sites/test_app/tmp/pids/unicorn.pid not writable
    

    检查一下这个文件或路径的权限,当前用户能访问不?(比如你之前用 root 启动,导致这个文件是 root 所有)

  • Github 的 Sourse 始终显示为 Javascript,明明是 Ruby 啊 at November 28, 2011

    因为这个问题我一有大 js 就包裹成 gem

  • ruby-china 帖子需要有一个关闭讨论的功能 at November 28, 2011

    今天不实现这个功能,明天网站会崩溃吗? 奥,不会,那先放着吧

  • devise 相关问题 at November 27, 2011

    #10 楼 @Jsiguo 设置了 root 之后出现了什么错误呢?

    PS:其实 devise 这个 gem 非常复杂,我也玩不转,我觉得还是自己写用户认证逻辑比较好,现在有 ActiveModel::SecurePassword 这个模块,已经处理了最麻烦的那部分。

  • devise 相关问题 at November 27, 2011

    undefined local variable or method `root_path'

    是否有在路由中设置 root?

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