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

[email protected]
深圳
182 篇帖子 / 9132 条回帖
727 关注者
0 正在关注
11 收藏
中下水平 Rails 程序员
打赏作者
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
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • 哎呀 土鳖来问一下 github 是什么啊?好像大家都有啊 at 2012年04月13日

    https://github.com/popular/watched 这些项目放在 github 上

    PS:珍惜生命,远离百度

  • rails 升级到 3.1.1 之后 js 就死活都不好使了 at 2012年04月13日

    浏览器打开这个文件 /assets/yanzheng.js,看看内容对了没

    然后你的 js 代码是什么,目的是什么。我在 1 楼没看见执行的部分。

  • 有多少人不喜欢 asset pipeline? at 2012年04月13日

    很喜欢。

    我的源码库里面不需要再提交外部的 js 代码了。 coffee 和 scss 无缝集成。

  • rails 升级到 3.1.1 之后 js 就死活都不好使了 at 2012年04月13日

    冷静一下,我还没看明白你想干啥呢。

    1. javascript 链接对了没
    2. 编译出来的 js 内容对了没
    3. 是不是 javascript 内容没写对

    我单看 1 楼不知道什么问题

  • rails 升级到 3.1.1 之后 js 就死活都不好使了 at 2012年04月13日

    rake assets:clean

  • 如何使用最新的 bootstrap css? at 2012年04月12日

    我推荐 https://github.com/seyhunak/twitter-bootstrap-rails

  • 什么时候 Google 让河蟹了? at 2012年04月12日

    因为启用了 Google 的安全搜索功能

    找找个人设置

  • 关于 rails 操作 MYSQL 的问题 at 2012年04月12日

    has_many :microposts, :foreign_key => "user_uid"

  • 关于 rails 操作 MYSQL 的问题 at 2012年04月12日

    前面是 Users#microposts 6 楼是 User#micropost

    楼主再检查下拼写

  • 神奇的空格 at 2012年04月12日

    #5 楼 @frankel good

  • ActionMailer 发不出去邮件 at 2012年04月12日

    就是证书的问题,怎么装单独一个证书我也不懂,可以围绕 ruby openssl certificate 搜搜一下

    或者不安全的把校验关掉 OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE

  • 关于 rails 操作 MYSQL 的问题 at 2012年04月12日

    class User first_user = Users.first

    类名打错了吧

  • model 中的虚拟属性 at 2012年04月11日

    …… 这就是 accessor 而已阿,怎么会有性能问题

  • rails 怎样使用迁移设定一个表的外键 at 2012年04月11日

    #5 楼 @413472212 你得先放下以数据库为中心的建模思路。ActiveRecord 有一套惯例,例如 User 和 Book 模型,对应 users 表和 books 表。

    # 表结构
    # users(id, ...)
    # books(id, user_id, ...)
    
    class User
      has_many :books
    end
    
    class Book
      belongs_to :user
    end
    
    # 使用场景
    user = User.new
    book = Book.new
    user.books << book
    user.save
    
    

    这样来完成数据保存。Rails 是先考虑模型层的建模,然后再根据模型层来准备数据库结构。可以看到因为在代码里面都是使用已有的数据对象来设置关联的,不会直接往数据库插入关联键的值。

    foreign_key 参数是指如果 books 变成了 (id, author_id, ...) 这样的结构,而需要用 author_id 和 User 模型建立关联,就需要用

    class User
      has_many :books, :foreign_key => :author_id
    end
    
    class Book
      belongs_to :user, :class_name => 'User', :foreign_key => :author_id
    end
    
    

    更多资料参考官方引导 http://guides.rubyonrails.org/association_basics.html

  • rails 怎样使用迁移设定一个表的外键 at 2012年04月11日

    #3 楼 @413472212 模型层的 belongs_to 只添加了模型层的关联方法,不会在数据库层加外键关联。不过在 Rails 社区习惯不依赖数据库而只做模型层关联。如果认为应用环境需要数据库层的关联校验,也可以加上数据库外键。

    :foreign_key 参数只是用来设置关联字段和关联名称不一致时的情况。

  • rails 怎样使用迁移设定一个表的外键 at 2012年04月11日

    用原生 SQL,例子 http://guides.rubyonrails.org/migrations.html#using-the-up-down-methods

  • 神奇的空格 at 2012年04月11日

    前几天我也遇到了,用 nokogiri 处理过的 html,&nbsp;会被 unicode nbsp 替换 http://en.wikipedia.org/wiki/Non-breaking_space

  • 求解:关于表间关联 at 2012年04月11日

    实例变量被重复赋值了。应该先在控制器拿到@arrangements,遍历交给视图

    控制器

    @arrangements = Arrangement.includes(:teacher, :banji, :kecheng).all
    
    
    
    
    

    视图

    <% @arrangements.each do |arrangement| %>
      <%= "#{arrangement.teacher.name} #{arrangement.banji.name} #{arrangement.kecheng.name}" %>
    <% end %>
    
    
    
    
    
  • 关于类似网易评论盖楼的数据库设计 at 2012年04月11日

    Trees in MongoDB http://www.mongodb.org/display/DOCS/Trees+in+MongoDB

    不单是说 mongodb,还说了其他设计思路

  • 如何在不同的页面加载不同的 js 文件? at 2012年04月11日

    #1 楼 @daqing 我也是这样

  • ruby-china 创建 notification 失败,怎么解? at 2012年04月11日

    没看明白阿,你做了什么

  • 求解:关于表间关联 at 2012年04月11日

    #16 楼 @douya0808 是的。限制存入用 validates

  • 为啥不加上私信功能? at 2012年04月10日

    #5 楼 @ericguo 我也这么觉得

  • 求解:关于表间关联 at 2012年04月10日

    假设用这个结构

    Teacher (...)
    Course (...)
    SchoolClass (...)
    Arrangement (teacher_id, course_id, school_class_id)
    
    
    class Teacher
      has_many :arrangements
      has_many :courses, :thougth => :arrangements, :uniq =>true
      has_many :school_classes, :thougth => :arrangements, :uniq =>true
    end
    
    class Course
      has_many :arrangements
      has_many :teachers, :thougth => :arrangements, :uniq =>true
      has_many :school_classes, :thougth => :arrangements, :uniq =>true
    end
    
    class SchoolClass
      has_many :arrangements
      has_many :teachers, :thougth => :arrangements, :uniq =>true
      has_many :courses, :thougth => :arrangements, :uniq =>true
    end
    
    class Arrangement
      belongs_to :teacher
      belongs_to :course
      belongs_to :school_class
    end
    
    # teacher 有课的班
    teacher.school_classes
    
    

    刚忘了说还有 :uniq 这个参数,用来去掉重复。

    我觉得这个结构是比较灵活的,熟悉 sql 的话可以做各种关联查询。

  • 求解:关于表间关联 at 2012年04月10日

    #7 楼 @douya0808 has_many :througth

    http://guides.rubyonrails.org/association_basics.html#the-has_many-through-association

  • 求解:关于表间关联 at 2012年04月10日

    Teacher (...) Course (...) SchoolClass (...) Arrangement (teacher_id, course_id, school_class_id)

  • 能不能给 mogonmapper 设置主键? at 2012年04月10日

    这是 mongodb 的特性,_id 不能去掉

  • 新人请教一个比较奇怪的问题 at 2012年04月10日

    #5 楼 @BBQ 这样应该是没有 home_mm_content_path 这个方法的,是不是还有别的路由


    看了下文档,好像还真有

    用

    home_mm_content_path(:id => post)
    
    
    

    试试

  • 新人请教一个比较奇怪的问题 at 2012年04月10日

    我奇怪匿名路由怎么会有 url herlper。

    楼主看的资料旧了,现在不会用 ':controller(/:action(/:id(.:format)))' 这样的匿名路由。

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