Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
Yuan Cheung
@zhangyuan
VIP
NO. 140 / 2011-11-20

北京
6 Topics / 558 Replies
10 Followers
0 Following
32 Favorites
I'm not the only one.
GitHub Public Repos
  • google-authenticator-e... 10

    A command line tool to extract secrets from Google Authenticator's QR code. 从 Google Authenticato...

  • proxymanager 2

    A simple tool to manage v2ray process and network proxy on MacOS

  • zender 1

    Compile templates written in Jinja, with metadata generated.

  • seo-helper 1

    A simple tool to generate SEO meta info with LLM.

  • dq 1

    A data quality check utility

  • amlogic-s9xxx-openwrt 0

    Support for OpenWrt in Amlogic, Rockchip and Allwinner boxes. Support a311d, s922x, s905x3, s905x...

  • securebin 0

    A simple application for sharing text securely with client side encryption.

  • git-server 0

    A simple demo for git server

  • qqwry-rs 0

    A library and program for IP address lookup using the qqwry.dat file.

  • stm32f103c8t6-blink-ar... 0

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • Rails session 是否会带来验证码没有意义 at April 23, 2012

    可以参考 redmine,把生成 secret_token.rb 从版本控制中去掉,然后写个 rake 任务来生成这个文件。在部署前执行这个命令。见 https://github.com/edavis10/redmine/blob/master/lib/tasks/initializers.rake

    Redmine 是 2.3 的

  • Rails session 是否会带来验证码没有意义 at April 23, 2012

    或者加密验证码后放进 cookie。手机太难用了,点不上编辑按钮。。。。

  • Rails session 是否会带来验证码没有意义 at April 23, 2012

    #3 楼 @Los 基于 cookie 的 session 不是加密的,只是被签名过的,放伪造,另外加上了 HttpOnly,所以只能通过 http 协议访问,js 得不到。

    可以把验证码加密后保存在 cookie 嘛,只要密钥没有泄漏。ActiveSupport 有个加密类的

  • Rails 的默认 return,躺着都中枪!大家小心啊... at April 22, 2012

    #12 楼 @ShiningRay 这个不是 filter,是 callback。controller 的 filter 的只能用 render 或者 redirect_to 打断。

  • will_paginate 是否支持非 model 的数据进行分页? at April 21, 2012

    #5 楼 @cdredfox 看源码 https://github.com/amatsuda/kaminari/blob/master/lib/kaminari/models/array_extension.rb

    给 Kaminari.paginate_array方法传递数组,和 :total_count参数。

    即

    Kaminari.paginate_array(my_array_object, :total_count => 100).page(params[:page]).per(10)
    
    
  • 这个 Gem 叫什么来着? at April 21, 2012

    我记得有些可以把中文替换成拼音,然后当做 slug。不晓得遇到多音字怎么办⋯⋯

  • rails3 中能够直接把 json 转换成 model 吗? at April 21, 2012

    如果 json 字符串可能包含 model 中没有的属性,那么说明,这个 json 对应的模型,和原来的模型不是一个东西吧?能否试试动态生成模型类?

    ActiveResource 就会把 JSON 数据,转换成对象:如果遇到哈希,则哈希的 key 作为类名。具体可以看看 ActiveResource::Base#find 方法: https://github.com/rails/rails/blob/3-2-stable/activeresource/lib/active_resource/base.rb

  • Sinatra 能够使用 Rails 的 Gem 吗? at April 21, 2012

    楼主可以先在 http://rubygems.org/ 里搜一下某个 gem,看看它的 Runtime Dependencies 有那些,如果依赖了 Rails,或者 ActiveRecord 等 rails 里的 gem,那么就只能在 rails 里用了。

  • 这个 Gem 叫什么来着? at April 21, 2012

    那个东东叫 slug,楼主可以搜一搜。

    我搜到一个 https://github.com/rsl/stringex

  • will_paginate 是否支持非 model 的数据进行分页? at April 21, 2012

    will_paginate 扩展了 Array,看一下源码就明白啦

    https://github.com/mislav/will_paginate/blob/master/lib/will_paginate/array.rb

  • foreign_key 放在哪里? at April 21, 2012

    首先,数据库里的“外键”abc_id,是放在 belongs_to 所在的模型上的。

    比如 a_models has_many b_models,并且 b_models belongs_to a_model,那么, belongs_to 上加 foreign_key,是在找关联对象 a_model 时,select * from a_models where id=b_model_id has_many 上加 foreign_key,是在找关联对象 b_models 时,select * from b_models b_model_id=id

    不同位置的 foreign_key,拼出来是不同的 SQL。这样说可以么?

  • 国内访问 rubygems.org 好慢啊,大家有没有提速的方法? at April 20, 2012

    把所需 gems 放在 vendor/cache 下面,就不用每次下载了。当然还得连 source。

    bundle package 可以把当前项目的 gem 保存到 vendor/cache。

  • 诡异的 SSH 登录! at April 19, 2012

    #18 楼 @linjunpop 当时一鸡冻,看错鸟~

  • 诡异的 SSH 登录! at April 19, 2012

    按照 #1 楼 @linjunpop 的方法,修改目录和文件权限,我这边的问题解决。非常感谢。

    不知道楼主有没有 ok?

  • 诡异的 SSH 登录! at April 18, 2012

    我也遇到这个问题,纳闷了好多天了。看楼上的回复,觉得是$HOME 目录的权限问题,因为公司测试服务器上的 $HOME 权限都有问题,经常有警告出现。明天去试试

  • 发起一个算法讨论, 取得素数. at April 14, 2012

    回想起大学时候数论是核心课程,现在忘得一干二净

  • rails 升级到 3.1.1 之后 js 就死活都不好使了 at April 13, 2012

    lz 冷静。我每次更新 rails 版本,就遇到一大堆问题。XD

  • rails 升级到 3.1.1 之后 js 就死活都不好使了 at April 13, 2012

    /assets/tab.js?body=1 /assets/yanzheng.js?body=1 /assets/application.js?body=1

    这三个文件里的内容,是否正确呢?

  • rails 升级到 3.1.1 之后 js 就死活都不好使了 at April 13, 2012

    lz 查看一下网页的源码,看看 js 的 URL 是否指向了正确的文件?

  • 做了个关于云推荐的网站,麻烦各位帮提提意见 at April 13, 2012

    导航 + 评价系统,有前途,(^__^) 嘻嘻……

  • 缓存引起的 Undefined Class/Module 有什么优雅的解决方法? at April 13, 2012

    #1 楼 @quakewang 题外话:现在不流行使用 alias_method_chain 了。rails-3 中使用 alias_method_chain 已经很少了,都是在模块中重写方法,必要时用 super 调用原来的方法,然后 include 到类中。 :)

  • 我的 linode 今天打不开了, 大家有出现吗? at April 12, 2012

    http://apple.com/ http://www.slideshare.net/

    都打不开(成都,不知道哪个宽带⋯⋯)

  • 神奇的空格 at April 11, 2012

    如果不能用文字展现,就用贴个图片吧

  • 关于类似网易评论盖楼的数据库设计 at April 11, 2012

    stackoverflow 上的一个总结(好棒的社区哇) ,不知道复制过来是否合适⋯⋯

    What are the Options for Storing Hierarchical Data in a Relational Database?

  • 关于类似网易评论盖楼的数据库设计 at April 11, 2012

    有好几种设计模型,各有优点,需要兼顾增删改查不同操作的效率。提供几个关键词供搜索 tree threaded hierarchical。

    另:

    1. reddit 貌似是开源的(记得至少以前的 webpy 版是开源的),可以看看代码,不过是 python 的。
    2. 推荐一种方案,基于 PATH 的。使用一个叫 ancestry 的 gem https://github.com/stefankroes/ancestry 。视频 http://railscasts.com/episodes/262-trees-with-ancestry 。如果深度不那么深,推荐一下。每次增删改,只影响一条记录。Postgres 有 ltree 模块,与这个设计思路应该是一样的。
    3. MongoDB 可以直接保存嵌套数据。但不能查找某一个评论。

    楼主研究透了,可以分享一下哈~

  • [原创] Ruby 初学者水平自测代码 at April 10, 2012

    如果使用 vim+snipmate.vim 的话。假设当前文件名为 foo.rb,输入 mod 后敲 Tab,然后敲 3,就会有如下补全:

    module Foo
      module ClassMethods
    
      end 
    
      module InstanceMethods
    
      end 
    
      def self.included(receiver)
        receiver.extend         ClassMethods
        receiver.send :include, InstanceMethods
      end 
    end
    
    
  • [求助] Nokogiri 抓取百度快照乱码处理 at April 09, 2012

    听说百度的编码似乎不一致,很奇怪。

  • system command 不执行 at April 09, 2012

    是不是权限问题?

    我记得默认 passenger 启动后,会以 nobody 用户处理请求;试试修改运行一下 passenger 的用户?

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