Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
Rei
@Rei
管理员
第 1 位会员 / 2011-10-28

[email protected]
深圳
188 篇帖子 / 9165 条回帖
731 关注者
0 正在关注
11 收藏
中下水平 Rails 程序员
打赏作者
GitHub Public Repos
  • writings 941

    [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**

  • geeknote 34

  • 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

More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • Ruby 如何发邮件?我是说不依赖第三方的发法 at 2013年01月10日

    mail 这个 gem,smtp 协议。

  • Rails 这次漏洞有点严重啊 at 2013年01月10日

    15 分钟 demo 已经很久不提了,最新是 Rails is Omakase,早前是 Rails is not for beginers.

  • Rails 这次漏洞有点严重啊 at 2013年01月10日

    这下是代码注入了,比较严重。

  • 使用继承技术的例子? at 2013年01月10日

    #5 楼 @dreamable 首先,慎用继承,如果 model 或者 contorller 有重复的代码,可以抽取 Concern http://37signals.com/svn/posts/3372-put-chubby-models-on-a-diet-with-concerns

    然后,Model 用了继承,Controller 不一定要继承,像 Ruby China 的消息通知(https://github.com/ruby-china/ruby-china/tree/master/app/models/notification)继承了同一个 model,但是 Controller 用的是同一个,一致的 read, destroy 行为。继承本来不就是让他们表现一样的行为么?消息通知用继承的原因是希望各类消息存在同一个集合。

    至于 View,if 处理没问题,或者像 Ruby China 这样利用局部模板

    <%= render :partial => "notifications/#{notification.class.name.underscore}", :locals => {:notification => notification} %>

  • 进行 ajax 操作时页面不刷新 at 2013年01月10日

    第一种方式是已经被废弃的 rjs 代码,没有 page.replace_html 这个方法了,所以是跑不通的。

  • 使用继承技术的例子? at 2013年01月10日

    为了使用继承而使用继承?

  • 如何设置动态的 FORM? at 2013年01月09日

    这是前端逻辑,用 javascript 实现。

  • Programming Ruby 中文版 (第 2 版) 这本书蛮好的 怎么就绝版了? at 2013年01月08日

    传统出版的弊端,每次印刷有个印量,根据销售情况加印。但在技术类书上,除非是热门书,不然都不会卖得很快,慢慢的后来的人就买不到了,出版社也不会加印。

  • 建议大家不要在社区谈 VP*N at 2013年01月07日

    #11 楼 @yhben 放在亚马逊 S3,躺着中枪。

  • 建议大家不要在社区谈 VP*N at 2013年01月07日

    #5 楼 @LinuxGit 上面的心思不要猜

  • 建议大家不要在社区谈 VP*N at 2013年01月07日

    既然什么想不到的词都能成为关键词,那就不要想了。

  • 脚本如何规避单引号的导致的 SQL syntax 问题? at 2013年01月06日

    ActiveRecord

  • 总结教训 at 2013年01月05日

    赞同 @reus ,简单最好。

    我上午发过一个贴,现在这个状况也适合:疏忽大意的危险在于每个人都认为自己没有疏忽大意。没有摔过跤,就总会觉得悲剧不会在自己身上发生。我也是挂过一次服务器才养成了每日备份的意识。

  • 虽然数据挂了,但是。。。哈哈 at 2013年01月05日

    想得美 XD

  • 难道你们还没学 Clojure ? at 2013年01月05日

    rework XD

  • 2012年12月21日以后的数据丢失了 at 2013年01月05日

    多年以后,我们仍未知道 2012.12.21 那天之后 Ruby China 发生了什么……

  • rails 下新建一个 blog 模板的问题 at 2012年12月20日
    # 给现有 topic 加 tag
    topic = Topic.find id
    Tag.create :name => 'tagname', :topic => topic
    
  • 关于 Rails 新手的一个问题 at 2012年12月18日

    app/assets/javascripts/home.js.coffee

    这个文件里面代码有错。

  • 关于 Rails 新手的一个问题 at 2012年12月18日
    1. 确认了删的是当前练习的项目的 index.html 文件
    2. 重启 rails s,浏览器强制刷新 Ctrl + F5
    3. 贴路由代码。
  • CarrierWave 导致的性能问题 at 2012年12月18日

    #2 楼 @gfreezy_ 如果生成的 url 是不变的,可以缓存或者储存下来。

  • CarrierWave 导致的性能问题 at 2012年12月18日

    没看见有七牛相关的代码啊?

  • 为什么不能更新主键? at 2012年12月14日

    #27 楼 @woody1983 http://apidock.com/rails/ActiveRecord/Associations/ClassMethods/belongs_to

    似乎是 :primary_key,我还没用过

    belongs_to :person, :primary_key => "name", :foreign_key => "person_name"

    如果你用默认的 id 做关联,就没必要经常更新外键了。

  • 为什么不能更新主键? at 2012年12月14日

    其实很明了了,AR 不支持更改 id,因为 id 的定义就是永远不改变的字段。

    像订单号这样的数据应该另开一个字段,因为人工定义的字段没什么是不变的,身份证号就变过一次。

  • ActiveRecord 得 find 有缓存嘛? at 2012年12月14日

    我不知道了,一个个 gem 去掉看看。

  • 为什么不能更新主键? at 2012年12月14日

    #23 楼 @woody1983 update_column 的意思就是脱离 AR 掌控更新一个字段

  • ActiveRecord 得 find 有缓存嘛? at 2012年12月14日

    #4 楼 @kaka 有部分查询逻辑被拆分到 origin 这个 gem 了

    mongoid 也有 identity_map_enabled 这个参数,有没有打开?

  • 为什么不能更新主键? at 2012年12月14日
    def update(attribute_names = @attributes.keys)
      attributes_with_values = arel_attributes_values(false, false, attribute_names)
      return 0 if attributes_with_values.empty?
      klass = self.class
      stmt = klass.unscoped.where(klass.arel_table[klass.primary_key].eq(id)).arel.compile_update(attributes_with_values)
      klass.connection.update stmt
    end
    
     def arel_attributes_values(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys)
      ...
    

    AR 特地吧 primary_key 排除了,就是不建议更新。一定要更新的话用 SQL 吧。

  • ActiveRecord 得 find 有缓存嘛? at 2012年12月14日
    def find_one(id)
      id = id.id if ActiveRecord::Base === id
    
      if IdentityMap.enabled? && where_values.blank? &&
        limit_value.blank? && order_values.blank? &&
        includes_values.blank? && preload_values.blank? &&
        readonly_value.nil? && joins_values.blank? &&
        !@klass.locking_enabled? &&
        record = IdentityMap.get(@klass, id)
        return record
      end
    
      column = columns_hash[primary_key]
    
      substitute = connection.substitute_at(column, @bind_values.length)
      relation = where(table[primary_key].eq(substitute))
      relation.bind_values = [[column, id]]
      record = relation.first
    
      unless record
        conditions = arel.where_sql
        conditions = " [#{conditions}]" if conditions
        raise RecordNotFound, "Couldn't find #{@klass.name} with #{primary_key}=#{id}#{conditions}"
      end
    
      record
    end
    

    如果 IdentityMap 没开应该没缓存啊。

    装了什么插件吗?

  • ActiveRecord 得 find 有缓存嘛? at 2012年12月14日

    有缓存

    update: 我查查先

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