Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
花错
@flowerwrong
Member
NO. 9442 / 2013-10-06

广州
47 Topics / 1109 Replies
36 Followers
35 Following
233 Favorites
人生有如花错
No GitHub.
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • Rails 利用 cancan 实现一个优雅可扩展的角色管理系统 at May 11, 2015

    #11 楼 @lyfi2003 n+1 是指?

  • [已解决] 省市区查询使用什么 gem?或其它实现方式? at May 11, 2015

    #14 楼 @chairy11 先复制下来,脚本处理

    class CreateChinaCities < ActiveRecord::Migration
      def change
        create_table :china_cities do |t|
          t.integer :area_code
          t.string :area
          t.integer :parent_code
          t.integer :level
    
          t.timestamps null: false
        end
      end
    end
    
    
    def w_f(f, tmp_arr, code, tail, level)
      f.puts tmp_arr[0] + ' ' + tmp_arr[1] + ' ' + code + tail + ' ' + level
    end
    
    f = File.new('./china_city_han.txt', 'w')
    File.open('./china_city.txt', 'r') do |file|
      while line  = file.gets
        if line[0] != "\n" && line[0] != "\r"
          tmp_arr = line.split(' ')
          # f.puts tmp_arr[0] + ' ' + tmp_arr[1] 3515
    
          1100.upto(8300).each do |k|
            # han_city(tmp_arr, k.to_s[0], k.to_s[1], k.to_s[2..3], f)
            a = k.to_s[0]
            b = k.to_s[1]
            c = k.to_s[2..3]
            code = a + b
            if tmp_arr[0].start_with?(code + '0000')
              f.puts tmp_arr[0] + ' ' + tmp_arr[1] + ' 0' + ' 1'
              break
            elsif tmp_arr[0].start_with?(code + c) && tmp_arr[0].start_with?(code + c + '00')
              w_f(f, tmp_arr, code, '0000', '2')
              break
            elsif tmp_arr[0].start_with?(code + c)
              w_f(f, tmp_arr, code, c + '00', '3')
              break
            end
          end
    
        end
      end
    end
    f.close
    
    
    # ChinaCity import to seeds.rb
    File.open(Rails.root.to_s + '/scripts/china_city_han.txt', 'r') do |file|
      while line  = file.gets
        if line[0] != "\n" && line[0] != "\r"
          tmp_arr = line.split(' ')
          if tmp_arr.length == 4
            cc = ChinaCity.new(
              area_code: tmp_arr[0].to_i,
              area: tmp_arr[1],
              parent_code: tmp_arr[2].to_i,
              level: tmp_arr[3].to_i
            )
            cc.save!
          end
        end
      end
    end
    
  • 新手请教下,大家使用过 ruby expect 么? at May 11, 2015

    #12 楼 @jasontang168 sshkit 这个?

  • Rails 利用 cancan 实现一个优雅可扩展的角色管理系统 at May 11, 2015

    给 12 个基本表设计的跪了

  • 感觉 Ruby 只是在 Web 方面应用的比较多 at May 10, 2015

    #14 楼 @qingxp9 头像赞

  • 感觉 Ruby 只是在 Web 方面应用的比较多 at May 10, 2015

    够了

  • [深圳] Soloman 嚯嚯 - 私人保镖 o2o ~ 招聘 Ruby 开发,2.5年 经验 + at May 09, 2015

    2.5 年经验从什么时候开始算?

  • 困扰了好几天了 at May 09, 2015

    我看了下源码,一共就一个文件,抽出来作为一个 module 直接用吧。 复用再做成 gem

  • 困扰了好几天了 at May 08, 2015

    cannot load such file -- TaoBaoApi/version (LoadError) 駝峯???

  • ruby-china 的 follow 功能是怎么实现的 at May 08, 2015

    acts_as_follower

  • [已解决] 省市区查询使用什么 gem?或其它实现方式? at May 06, 2015

    有一个官方数据源,但最新更新到 13 年底 还有一个可参考,qq ip 页面,纯 J's 的,已经有人拔下来了,自己拔也不难。第三方 gem 没用过。 还可以拔比如微信,人人的省市区数据,应该比官方还靠谱点。 不在电脑旁,链接回去再补,你可以搜索下,关键词都给了。 P'S 我用的官方数据,存数据库,有错再改。

  • RailsConf 2015 视频 720p at May 05, 2015

    赞赞赞

  • Rails 中的事务处理 at May 05, 2015

    挺棒的

  • 写起 Python 来各种不习惯…… at May 05, 2015

    写过一段 python,没深入。还是比较喜欢 ruby,不喜欢 python 的 Len(arr), def say:, 还有类继承。

  • [上海] 100offer 招聘 Rails 开发 at May 04, 2015

    #1 楼 @ruby_sky ……

  • Mac 下的数据库设计软件? at May 04, 2015

    我用yaml

  • 电子商务网站一般怎么报价 at May 01, 2015

    #20 楼 @tini8 之前我选了 pod,评价比 ACF 高,你可以试下。还可以去看看 drupal 的自定义文章类型实现。

  • 电子商务网站一般怎么报价 at May 01, 2015

    #18 楼 @tini8 还不是加表,或者写到 meta 表里面

  • [ 已解决 - 更新解决方案 ] 如果在这里问大家怎么对付蚊子的,会不会被拍死? at May 01, 2015

    男朋友干啥去了

  • [广州天河区] 大型网络游戏公司招聘资深服务端开发工程师一名 [35W] at April 30, 2015

    游戏不是主要 c++ and erlang 吗? c++ 心累了?

  • Ruby 中 load 文件的原理是什么? at April 29, 2015

    eval?猜的

  • has_one 的疑问 at April 29, 2015

    after_create,看你的需求应该只是想初始化的时候创建 profile,你可以 google after_create和after_save的区别,after_create只在对象创建的时候只执行一次

    class User < ActiveRecord::Base
      has_one :profile, dependent: :destroy
      after_create :build_profile
      private
        def build_profile
          Profile.create!(user_id: self.id, role: 'Admin', avatar: 'ooxx.png')
        end
    end
    
    class Profile < ActiveRecord::Base
      belongs_to :user
    end
    
  • 电子商务网站一般怎么报价 at April 29, 2015

    #5 楼 @robot_zhang 国内的市场都被打乱了。国际支付是个突破口。

  • 电子商务网站一般怎么报价 at April 29, 2015

    最少也得 50000+

  • 用了 Ruby 以后,发现瓶颈已不在数据库,而在语言 at April 29, 2015

    #35 楼 @luikore 太帅

  • [上海] 爱客 CRM 招聘高级 Ruby 工程师! at April 28, 2015

    #16 楼 @yystage 你的个人介绍,哈哈哈哈哈哈

  • [上海] 爱客 CRM 招聘高级 Ruby 工程师! at April 28, 2015

    #9 楼 @eryu 妹子图呢?难道是我打开的方式不对?

  • 那些不常更改的内容,你们怎么设置的? at April 27, 2015

    給別人做的那麼還是新建page數據表或者直接post數據表,post_type是page. 自己做主要看前端,那就沒所謂了。我做過的通常都是這樣乾的,至於寫入文件,這事我也幹過。比如寫進 yaml.

  • 总结一下 Ruby 中的对象和类模型 at April 26, 2015

    :plus

  • Rails 集群部署问题 at April 26, 2015

    #8 楼 @boyishwei :plus1: 还有一个问题,怎么处理多地甚至多国服务器呢? 我的想法:

    1. 一个总代理,根据 IP 判断地区和国籍,再走下一层分代理
    2. DNS 层做负载均衡,具体未知
  • Prev
  • 1
  • 2
  • …
  • 13
  • 14
  • 15
  • 16
  • 17
  • …
  • 35
  • 36
  • Next
关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English