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
  • 怎样与别人的前端代码合并? at June 08, 2015

    #21 楼 @chairy11 我们公司缺人 😄

  • 怎样与别人的前端代码合并? at June 08, 2015

    #15 楼 @chairy11 1、第一步,你费事整合下 2、然后你们在同一个 repo 下共同开发 3、大家都遵循你们公司的规范 4、找个第三者做代码审查,不规范,打回重写

  • 怎样与别人的前端代码合并? at June 07, 2015

    #2 楼 @chairy11 oh, no. 你们公司规范呢?

  • 怎样与别人的前端代码合并? at June 07, 2015

    整合下,丢 assets 下面,rails 自带的挺好用。 居然都是女生!!!

  • [上海][2015年6月9日] Ruby 聚会召集 at June 06, 2015

    能远程实时同步直播嘛?

  • Grape 怎么返回 HTML? at June 05, 2015

    Sinatra + grape 吧 或者直接上 rails

  • 基于 Rails 1.X 的核心项目的重构? at June 05, 2015

    #13 楼 @prajnamas 赞,逐步替换,保证了项目一直可用。

  • Rails 里在 helper 中写了方法,怎么在 controller 中调用 at June 04, 2015

    Use include, like this:

    class ApplicationController < ActionController::Base
      # Prevent CSRF attacks by raising an exception.
      # For APIs, you may want to use :null_session instead.
      protect_from_forgery with: :exception
    
      include ApplicationHelper
    
      layout false
    end
    
  • 求一些 Rails 常用的 Gem at June 03, 2015
    Gem list for development
    • awesome_print
    • better_errors
    • brakeman
    • rails_best_practices
    • pry
    • pry-rails
    • did_you_mean
    • capistrano
    • byebug
    • spring
    • simplecov
    • factory_girl
    • database_cleaner
    • seed-fu
    Gem list for production
    • acts-as-taggable-on
    • kaminari
    • active_model_serializers
    • mini_magick
    • carrierwave
    • jbuilder
    • bcrypt
    • rack-cors
    • rails-api
    • grape
    • mailboxer
    • acts_as_follower
    • devise
    • cancancan
    • rolify
    • vines
    • ruby-jwt
    • acts_as_tree
    • exception_notification
    • acts_as_list
    • br_star
    • backup
    • validates_url
    • slanger
    • awesome_nested_set
    • acts_as_commentable_with_threading
    • rubocop
    • sidekiq
    • resque
    • social_stream
    • unread
    • whenever
    • redis-objects
    • rabl
    • puma
    • foreman
    • god
    Gem list for test
    group :development, :test do
      # Call 'byebug' anywhere in the code to stop execution and get a debugger console
      gem 'byebug'
      # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
      gem 'spring'
    
      gem 'awesome_print', require: false
      gem 'brakeman', require: false
      gem 'rails_best_practices', require: false
      gem 'rubocop', require: false
      gem 'simplecov', require: false
      gem 'better_errors'
    
      # gem 'spring-commands-rspec'
      # gem 'email_spec'
      # gem 'timecop'
      # gem 'vcr'
      # gem 'fakeweb'
    
      # for test
      gem 'rspec-rails'
      gem 'factory_girl_rails'
      gem 'database_cleaner'
    end
    
    group :development do
      gem 'letter_opener'
    
      # deploy
      #gem 'capistrano'
      #gem 'capistrano-rvm'
      #gem 'capistrano-rails'
      #gem 'capistrano-bundler'
      #gem 'capistrano3-puma'
    end
    
    group :test do
      gem 'shoulda-matchers'
      gem 'ffaker'
    end
    
    Gem list for doc
    • rdoc
    • sdoc
    • yard
    • ruby-style-guide
  • 使用 Rails 构建 API 实践 at June 03, 2015

    #38 楼 @kayakjiang Thx. 😄 But for someone stepping in to a legacy code base, and adding regression tests, it was very surprising. I am very surprising.

  • 使用 Rails 构建 API 实践 at June 03, 2015

    你有做 spec controller 吗?

    require 'rails_helper'
    require 'awesome_print'
    
    RSpec.describe Api::V1::UsersController, type: :controller do
      describe "GET #show" do
        before do
          @user = create :user
          @request.headers['Authorization'] = "Token token=#{@user.authentication_token}, email=#{@user.email}"  # 问题point
        end
    
        after do
          @request.headers['Authorization'] = nil
        end
    
        it "returns http success" do
          get :show, { id: @user.to_param, format: :json }
          ap response.body  # 此处有一个奇怪的反应,打印 "" 这个""不知从何处而来。原因是加入了@request.headers['Authorization'] = "xxx“的设置,去掉就正常返回。
          json_hash = JSON.parse(response.body)
          expect(json_hash['code']).to eq(200)
        end
      end
    end
    

    console log

    ""
    F
    
    Failures:
    
      1) Api::V1::UsersController GET #show returns http success
         Failure/Error: json_hash = JSON.parse(response.body)
         JSON::ParserError:
           A JSON text must at least contain two octets!
         # /home/yy/.rvm/gems/ruby-2.1.6/gems/json-1.8.2/lib/json/common.rb:155:in `initialize'
         # /home/yy/.rvm/gems/ruby-2.1.6/gems/json-1.8.2/lib/json/common.rb:155:in `new'
         # /home/yy/.rvm/gems/ruby-2.1.6/gems/json-1.8.2/lib/json/common.rb:155:in `parse'
         # ./spec/controllers/api/v1/users_controller_spec.rb:20:in `block (3 levels) in <top (required)>'
         # ./spec/support/database_cleaner.rb:10:in `block (3 levels) in <top (required)>'
         # /home/yy/.rvm/gems/ruby-2.1.6/gems/database_cleaner-1.4.1/lib/database_cleaner/generic/base.rb:15:in `cleaning'
         # /home/yy/.rvm/gems/ruby-2.1.6/gems/database_cleaner-1.4.1/lib/database_cleaner/base.rb:92:in `cleaning'
         # /home/yy/.rvm/gems/ruby-2.1.6/gems/database_cleaner-1.4.1/lib/database_cleaner/configuration.rb:86:in `block (2 levels) in cleaning'
         # /home/yy/.rvm/gems/ruby-2.1.6/gems/database_cleaner-1.4.1/lib/database_cleaner/configuration.rb:87:in `call'
         # /home/yy/.rvm/gems/ruby-2.1.6/gems/database_cleaner-1.4.1/lib/database_cleaner/configuration.rb:87:in `cleaning'
         # ./spec/support/database_cleaner.rb:9:in `block (2 levels) in <top (required)>'
    

    database_cleaner config

    RSpec.configure do |config|
    
      config.before(:suite) do
        DatabaseCleaner.strategy = :transaction
        DatabaseCleaner.clean_with(:truncation)
      end
    
      config.around(:each) do |example|
        DatabaseCleaner.cleaning do
          example.run
        end
      end
    
    end
    
  • 如何优雅的用 js 动态添加 html 代码? at June 03, 2015

    前端模板引擎

  • 请问如何一键把另一个网站的内容「搬」到 Rails 的 #new 表单里面来? at June 01, 2015

    我觉得最大的问题在于账户的同步

  • 才发现 36 氪使用 Ruby China 二次开发的呀 at May 31, 2015

    #4 楼 @lips 我不是 36 氪的,不知

  • 前端架构分享 at May 29, 2015

    :plus1:

  • Rails API 服务器选择 at May 25, 2015

    puma/unicorn/passenger/thin 其实用了再说吧。提前预测是好事。

  • ubuntu 下 rvm 在 oh-my-zsh 下出现了的问题 at May 22, 2015

    #6 楼 @rei 配置了,其他.bashrc .bash_profile .profile 里面的 rvm 配置都删除了。只保留了.zshrc 里面的。 我没理解你说的第一位是什么意思? export PATH=$PATH:rvm_path

  • ubuntu 下 rvm 在 oh-my-zsh 下出现了的问题 at May 22, 2015

    我也有这个问题,各种谷歌,stackoverflow 无果,ruby 重装了好几遍,最后卸载了oh-my-zsh。

    rvm curWarning! PATH is not properly set up, '/home/xiajian/.rvm/gems/ruby-1.9.3-p551@tophold/bin' is not at first place,
             usually this is caused by shell initialization files - check them for 'PATH=...' entries,
             it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
             to fix temporarily in this shell session run: 'rvm use ruby-1.9.3-p551@tophold'.
    current 
    
  • undefined method `admin_advertises_path' 路由报错 help!!!!!! at May 21, 2015

    #12 楼 @string2020 完全是个人喜好,用了 N 年 vim 又怎样,我认识一哥们 N 年后换了 sublime。我系统装了 atom, vim, sublime, rubymine,每次第一个出现在脑海的名字就打开。

  • 如何使用 Node.js 完成 SMS 相关业务? at May 19, 2015

    你应该全部贴在这里,有兴趣的才去关注微信号。

  • 如何在 Rails 加载后,自动设置一个 session 值? at May 15, 2015

    application controller 啊

  • 这样的团队能去么? at May 14, 2015

    #17 楼 @ruby_sky …

  • [已解决] Carrierwave 如何配置合理的上传文件名?+ 怎样在上传之前直接显示预览图片? at May 13, 2015

    #5 楼 @chairy11 后面那些带前缀的是 rmagick 或者 minimagick 处理的 补充一下,ruby-china 的 baseuploder 是抽出来的,给其他继承用,外面用的是它的子类。。。见 AvatarUploader

    # encoding: utf-8
    
    class ImageUploader < CarrierWave::Uploader::Base
    
      # Include RMagick or MiniMagick support:
      # include CarrierWave::RMagick
      include CarrierWave::MiniMagick
    
      # Choose what kind of storage to use for this uploader:
      storage :file
    
      # 存放目录,打印出来看看嘛
      def store_dir
        p model.class.to_s.underscore
        p mounted_as
        p model.id
        "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
      end
    
      # 这里的就是minimagick处理的,文件名会保存为thumb_#{MD5}.extention(png/jpg),也就是上面多出的四个带前缀的文件,big_xxx.png。相当于resize为200*200,下同
      version :thumb do
        process :resize_to_fit => [200, 200]
      end
    
      version :small do
        process :resize_to_fit => [32, 32]
      end
    
      version :mid do
        process :resize_to_fit => [48, 48]
      end
    
      version :large do
        process :resize_to_fit => [72, 72]
      end
    
      # 格式白名单
      def extension_white_list
        %w(jpg jpeg gif png)
      end
    
      # 文件名没必要纠结吧,有中文就写成这个
      def filename
        if original_filename
          @name ||= Digest::MD5.hexdigest(File.dirname(current_path))
          "#{@name}.#{file.extension}"
        end
      end
    end
    
    
  • Rails 中自动布署工具 mina 的经验谈 at May 12, 2015

    又出新品啦!赞

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

    #17 楼 @gazeldx 其实还有一个 user<->user resources<->resources

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

    #17 楼 @gazeldx 其实还有一个 user<->user resources<->resources

  • 造个小轮子 - 中国省市区级联选择插件 for Angular at May 12, 2015

    哥们哪里人?

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