Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
@zhenjunluo
高级会员
第 2614 位会员 / 2012-06-21

北京
8 篇帖子 / 81 条回帖
1 关注者
0 正在关注
67 收藏
未设置 GitHub 信息。
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • 我觉得想学好用好 Rails 必须具备以下 2 点 at 2012年09月08日

    短时间是不会有什么收获的,最重要的坚持和积累,积累可以理解为不断的修改自己写过的程序,使之越来越好

  • Methods chain: Rails 中像 Scope 这样使用函数的方式是怎么实现的? at 2012年09月08日

    #16 楼 @reus 嗯,之前就是觉得既要返回 self 又要返回处理结果!perl 的话,以后在接触了

  • Methods chain: Rails 中像 Scope 这样使用函数的方式是怎么实现的? at 2012年09月08日

    http://asciicasts.com/episodes/239-activerecord-relation-walkthrough 这里有讲到 Rails 中 Relation 的实现

    http://stackoverflow.com/questions/5844598/what-is-an-activerecord-rails-relation-really stackoverflow 上面相关的一个问题

  • Rails 技巧之 tap & try at 2012年09月08日

    很有用!

  • 性能提示 at 2012年09月07日

    #7 楼 @zmbacker <<直接修改原来字符串内容?假设分配给原来字符串的内存就不够呢?如果这样的话,+=也可以直接修改原来字符串的内容啊,有什么不对的?

  • Methods chain: Rails 中像 Scope 这样使用函数的方式是怎么实现的? at 2012年09月07日

    #13 楼 @reus 这样虽然可以,可返回 self,需要的是返回处理结果而不是 self 本身

  • Methods chain: Rails 中像 Scope 这样使用函数的方式是怎么实现的? at 2012年09月06日

    #11 楼 @reus 很抱歉,这段代码举了个例子,可能不好!我想弄明白像 Rails 中用 Scope 定义的函数,假设为 A B C, 让后我就可以这样使用 Model.A.B.C,这是怎么实现的!知道的话讲下原理啊

  • Methods chain: Rails 中像 Scope 这样使用函数的方式是怎么实现的? at 2012年09月06日

    #7 楼 @reus Comm.should_receive(:find).with(:all).and_return([mock_comm]) 我是想知道像这样的方式是怎么实现的

  • Methods chain: Rails 中像 Scope 这样使用函数的方式是怎么实现的? at 2012年09月06日

    #7 楼 @reus 假设类名不是 String 呢?

  • Methods chain: Rails 中像 Scope 这样使用函数的方式是怎么实现的? at 2012年09月06日

    #5 楼 @jjym 我只是用字符串举个例子,我的目的是把自定义的函数连起来调用,测试中也有很多这样的用法,比如:

     describe "responding to GET index" do
    
        it "should expose all comms as @comms" do
          Comm.should_receive(:find).with(:all).and_return([mock_comm])
          get :index
          assigns[:comms].should == [mock_comm]
        end
    # ...
    

    Comm.should_receive(:find).with(:all).and_return([mock_comm]) 这样是怎么实现的?

  • Methods chain: Rails 中像 Scope 这样使用函数的方式是怎么实现的? at 2012年09月06日

    #3 楼 @chucai Relation 和 ruby 中 String 的表现很像

    str = String.new("hello")     ### 结果为"hello",为什么不是<String:0x8b4f390>这种形式呢?
    s = My_string.new("hello")  ### 结果为<My_string:0x8b4f390 @m_string="hello">
    
  • [新手向] ActiveRecord::Base 与 ActiveRecord::Relation 关系及基本原理 at 2012年09月06日

    写个简单的版本出来啊

  • Methods chain: Rails 中像 Scope 这样使用函数的方式是怎么实现的? at 2012年09月06日

    #1 楼 @jjym 什么意思?

  • Rails 不能载入 assets at 2012年09月06日

    ruby china 中是这样实现的

    application_helper.rb
    
     def controller_stylesheet_link_tag
        case controller_name
        when "users","home", "topics", "pages", "search", "sites", "notifications"
          stylesheet_link_tag controller_name
        when "replies"
          stylesheet_link_tag "topics"
        end
      end
    
      def controller_javascript_include_tag
        case controller_name
        when "pages","topics","sites", "notifications"
          javascript_include_tag controller_name
        when "replies"
          javascript_include_tag "topics"
        end
      end
    
    application.html.erb
    <%= controller_stylesheet_link_tag %>
    

    controller_name 是 rails 实现的,返回当前所访问的 controller

  • 建议把这个小贴士去掉吧. at 2012年09月04日

    #55 楼 @happypeter 说的有点意思,最后一句话,呵呵

  • RubyConfChina 2012 预热帖 at 2012年09月01日

    #104 楼 @fredwu 确实很喜欢这个页面

  • [吐血之作] 你可能错过的 Rails 技巧 at 2012年09月01日

    收藏了!

  • 说一说你最最常用的 linux 命令有哪些,也算是给新手指导 at 2012年09月01日

    lsof -iTCP:3000 用来查看占用端口 3000 的进程 kill -9 pid 结束进程号为 pid 的进程

  • [北京] 靠谱创业公司诚招技术主管 at 2012年08月29日

    看来下视频 demon,感觉挺好的

  • 菜鸟求助:初学者需要把代码都弄清楚吗? at 2012年06月21日

    我学 rails 差不多一个月了,railstutorial 教程和 depot 例子,在我电脑上敲了不下 3 遍,我觉得重点是弄清楚数据的传递(也可以说是参数的传递吧),rails 中大多数使用 hash 来传递参数,遇到最多应该数 params 了吧,可以制造点错误出来,然后就可以看到 params 中的信息了,也可以用 firebug 来查看以下需要提交的参数信息

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