Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
fan124
@fan124
Member
NO. 26523 / 2016-05-15

fangnan124@gmail.com
------
东京
7 Topics / 63 Replies
0 Followers
0 Following
9 Favorites
GitHub Public Repos
  • pisces_pieces 0

    When I want to know what I have in a second.

  • cheezecake_blog 0

    A tech blog to share knowledge(cheeze: 知识).

  • railsapp 0

  • archive 0

  • kafka_playground 0

    An example using Kafka with ruby-kafka & racecar gems.

  • challenge01 0

  • github_file_explorer 0

  • myapp 0

    rubyonrails

  • nodejstest 0

    nodejs test

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 使用 Devise Token 认证,登录被拦截, at November 08, 2019

    应该是去掉 before_action :authenticate_sys_user! 就可以了,用 token 做验证时只需要 include DeviseTokenAuth::Concerns::SetUserByToken。

  • 2019 年 了,是什么让你能够坚持使用 Ruby,或者是什么让你放弃了 Ruby? at August 01, 2019

    Active Record

  • Enumize - 扩展 ActiveRecord::Enum 增加实用方法 at June 25, 2019

    https://github.com/zmbacker/enum_help
    这个也是类似的

  • Rails has_many 定义问题 at May 29, 2019

    错误信息里没有LEFT OUTER JOIN m_selectlists,说明m_selectlists表没有被连接,
    你的PrevdetailTmpmodel 里有声明 belongs_to :m_selectlist了吗?

  • 如何合并这两条语句 at May 16, 2019
    a = (a || 0) + 1
    
  • 怎么实现对查询结果计数 at May 15, 2019

    试试这个

    Test
      .select(
        :result,
        'COUNT(result) AS results_count'
      )
      .where(id: 100)
      .group(:result)
    
  • react and rails 最佳实践? at December 17, 2018

    webpacker

  • Rails 开发 SPA 项目 at August 09, 2018

    原生行为不是异步请求,所以请求完之后会“换”页面,所以就不是 SPA 了吧

  • Rails 开发 SPA 项目 at August 09, 2018

    做 SPA 的话,表单应该不是直接提交的吧,而是监听表单的 submit 事件,并且用 event.preventDefault() 阻止表单的默认动作,再调用 api 去提交表单数据。

    Rails 那边的 api 的 controller 要继承自 ActionController::API,这样就不会有 CSRF token 的验证了,至于为什么不需要 CSRF token 请参考#7 楼

  • 使用 docker-sync 让 mac 和 docker 之间的文件同步变快 at August 07, 2018

    速度慢是因为 Asset Pipeline 编译时会在 tmp 下产生很多临时文件,而 mac 和 container 的文件系统不一样,同步时需要做大量的格式转换。 (docker 好像没有配置可以让部分文件或文件夹不做同步)

    我这里用的 UI 是在网上购买的,所以带了很多 js 和 css 文件,8000 多个吧(docker-compose up 之后第一次载入需要 2 分钟),我把大部分暂时没有用到的 assets 删除之后就变快了(第一次载入不到 20 秒)。

  • 使用 docker-sync 让 mac 和 docker 之间的文件同步变快 at August 06, 2018

    最标准的解决方案应该是在 Linux 系统上使用 docker。😂 😅
    买台电脑装 linux 系统做开发

  • 使用 docker-sync 让 mac 和 docker 之间的文件同步变快 at August 06, 2018

    我用 docker-sync 时,同步会有延迟,改代码之后要把页面刷两三遍,才有反应,而且 container 里 rails g 出来的东西,不会在 local 出现,需要重启 docker 才行,推荐用官方的 cached
    https://docs.docker.com/docker-for-mac/osxfs-caching/

    services:
      app:
        volumes:
          - .:/www/sample_project:cached
    
  • Ruby 对 csv 文件进行统计 at August 03, 2018

    用 postgres 的 COPY 把 csv 导入到数据库,然后用 activerecord,count 一下。数据量大时处理速度应该会比直接读 csv 快。

  • [远程-北京 / 武汉 / 新加坡 / 硅谷] Workstream 招聘 Ruby 和 ReactJS 工程师 (美金 $2500 - $4500/月) at June 11, 2018

    中文简历就可以了吗?

  • 在 Rails 中实现拖拽排序功能 at April 28, 2018

    我这里的做法是把顺序以 array 格式单独存在另一个表里,这样每次只更新一次,当然这样做的话,读取时要读两张表,或者 join 两张表。

  • 项目每次重新部署后,第一次打开页面都很慢,有时甚至报 504 超时 at April 19, 2018

    我这里也出现同样的问题,但是我这里是开发环境,也是 application.html.erb,去掉 stylesheet_link_tag 就没问题,就算 application.css 是空的,只要有 stylesheet_link_tag,重启后第一次载入页面速度就会特别慢,第二次开始又不会有问题,每次都是重启后的第一次慢,你的 rails 是 5.2.0 吗?

  • Rails 升级只升级 Gemfile 里面的 gem 行吗?总感觉不放心 at April 19, 2018

    在 Gemfile 里改 rails 版本, 执行bundle update rails, 再执行rails app:update, 如果问要不要覆盖文件,就选 Y。

    再做rails webpacker:install和webpacker:install:react, 如果问要不要覆盖文件,就选 Y。

    再把覆盖过的文件和之前版本比较、修正、commit。

  • Rails 查询数据库,去重求救 at April 14, 2018

    @jl5161 4 楼的逻辑可以

  • Rails 查询数据库,去重求救 at April 13, 2018

    从给的例子来说,最后要得到 a,b 和 c,a 对吗?

  • [北京] mango 正芒科技 高薪招聘 Ruby 工程师 20K~35K at March 27, 2018

    Ruby 大拿技术如火纯青也只能 15K 起😁

  • [北京] 途家海外事业部 招聘 Ruby 工程师 (20K-40K) at March 12, 2018

    面试可以远程吗?

  • [北京] Airbnb 中国 招聘 full stack engineer/mobile engineer (长期有效, 2018 已更新) at February 06, 2018

    可否远程面试?

  • 请问各位大佬,在已知一个 url 的情况下有什么办法能确定这个 url 对应的路由辅助方法 at January 02, 2018

    服务器启动,然后在这里可以查到 localhost:3000/rails/info/routes

  • 有什么推荐 PostgreSQL 的 GUI 软件吗?付费免费都可以,关键好用。 at October 29, 2017

    我现在是直接用 RubyMine,自带跟 DataGrip 一样的功能

  • 有什么推荐 PostgreSQL 的 GUI 软件吗?付费免费都可以,关键好用。 at October 28, 2017

    DataGrip 怎么样

  • [北京] Airbnb 全栈工程师 - 北京 - 写代码,也拥抱生活 at August 09, 2017

    😱

  • 关于 Rails 的 Model 和 Controller 之间传值的问题? at August 03, 2017

    试试这个,虽然不是传值,但是好像能解决你的问题

    # model
    with_options on: :checked do |model|
      model.validates :platform, presence: true
      # 如果以后有别的验证,这里可以多加几个validates
    end
    
    # controller
    if something_is_true?
      model.valid?(context: :checked)
    else
      model.valid?
    end
    
  • [北京] 美信生活 (A 轮) 诚邀 Ruby 后端 / 全栈工程师的加入 ( 9-15k)! at July 26, 2017

    年底真的 13 薪吗?😱

  • Ajax 获取数据之后,前端不显示 at July 14, 2017

    还可以试试这个,语法可能有错误,因为没跑过,大概是这个流程

    
    class XxxController < ApplicationController
      def hoge
        # xxxxxxxxxxxxxxxxx
        @system_dom = ProductCatalog.where('parent_id =?', params[:soft_selectid] ).map{|t| { name: t.name, id: t.id} }
        render :json => { :software_kingdom => @product_ware.first.id, system_dom: @system_dom.to_json}
      end
    end
    
    success: function(data){         
               $('#app_project_software_kingdom').val(data.software_kingdom);
               data.system_dom.forEach(function(dom) {
                 $('#system_domain').append('<option value="' + dom.id + '">' + dom.name + '</option>');
               });
             }
    
  • 1
  • 2
  • 3
  • Next
关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English