Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
windy
@lyfi2003
VIP
NO. 121 / 2011-11-17

[email protected]
深圳至简天成科技有限公司
深圳
120 Topics / 1217 Replies
350 Followers
7 Following
6 Favorites
技术测评,就用 ShowMeBug!
Reward
GitHub Public Repos
  • cywin 325

    Cywin Closed( Chinese name: 创业赢 )

  • wblog 217

    The missing independent blog system for Ruby on Rails

  • ruby-vimrc 91

    A quick vimrc for Ruby on Rails programming

  • ruby_proxy 9

    https://github.com/windy/ruby_proxy

  • mina-ng-puma 7

    Next generation mina-puma

  • remix-saas 0

    A Lightweight, Production-Ready Remix Stack for your next SaaS application.

  • wblog_2 0

  • FastAPITodoList 0

  • xz-first-vision 0

  • glassmorphism-bookstore 0

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • rails 已经安装成功后,使用短时间后,系统突然提示 “rails 尚未安装” at February 12, 2012

    这种直接 google 吧。简单提示下,编写/etc/.bash_profile 或 ~/.bashrc 具体$PATH 根据你 ruby 的安装目录来定的。

  • rails 中实现 windows 集成认证 at February 12, 2012

    Rails 肯定要知道相关密码 (也许是加密后的),然后传给 LDAP 作认证,通过了 rails 就可以认为 OK 了,创建好 session 的登录信息就可以了。 可以参考以下的 model:( 来自 stackoverflow )

    require 'net/ldap'
    
    class User < ActiveRecord::Base
    
      def after_initialize
        @config = YAML.load(ERB.new(File.read("#{Rails.root}/config/ldap.yml")).result)[Rails.env]
      end
    
      def ldap_auth(user, pass)
        ldap = initialize_ldap_con
        result = ldap.bind_as(
          :base => @config['base_dn'],
          :filter => "(#{@config['attributes']['id']}=#{user})",
          :password => pass
        )
        if result
          # fetch user DN
          get_user_dn user
          sync_ldap_with_db user
        end
        nil
      end
    
      private
      def initialize_ldap_con
        options = { :host => @config['host'],
                    :port => @config['port'],
                    :encryption => (@config['tls'] ? :simple_tls : nil),
                    :auth => { 
                      :method => :simple,
                      :username => @config['ldap_user'],
                      :password => @config['ldap_password']
                    }
                  }
        Net::LDAP.new options
      end
    
      def get_user_dn(user)
        ldap = initialize_ldap_con
        login_filter = Net::LDAP::Filter.eq @config['attributes']['id'], "#{user}"
        object_filter = Net::LDAP::Filter.eq "objectClass", "*" 
    
        ldap.search :base => @config['base_dn'],
                    :filter => object_filter & login_filter,
                    :attributes => ['dn', @config['attributes']['first_name'], @config['attributes']['last_name'], @config['attributes']['mail']] do |entry|
          logger.debug "DN: #{entry.dn}"
          entry.each do |attr, values|
            values.each do |value|
              logger.debug "#{attr} = #{value}"
            end
          end
        end
      end
    end
    
  • rails 已经安装成功后,使用短时间后,系统突然提示 “rails 尚未安装” at February 12, 2012

    一般来说是系统变量没有设置导致的。

  • rails 中实现 windows 集成认证 at February 12, 2012

    用 ruby-ldap 这个 gem

    然后,大概的代码如下,然后就跟密码认证差不多了:

    require 'ldap'
    
    conn = LDAP::Conn.new( '<domain-server>', 389 )
    conn.set_option( LDAP::LDAP_OPT_PROTOCOL_VERSION, 3 )
    conn.bind( '<domain>\<username>', '<password>' ) do |conn|
    
    base = 'ou=Users,ou=<container>,dc=<domain>,dc=local'
    
    results = conn.search2(base, LDAP::LDAP_SCOPE_SUBTREE, '(cn=*)')
    results.each { |entry| puts "#{entry['dn']}: #{entry['telephoneNumber']}" }
    
    end
    

    或者用这个 gem: net-ldap 参考: http://stackoverflow.com/questions/3539501/rails-ldap-login-using-net-ldap

  • Ruby 用在哪里? at February 12, 2012

    做自动化测试开发,华为,中兴,腾讯,百度都有。

  • ruby-china 最新代码启动开发环境的 mongodb 异常 at February 11, 2012

    thx,试试看

  • 致社区的两点建议 at February 10, 2012

    定期推送一些讨论贴子是可以的~

  • Mongoid 的 embedded_in 多层嵌入的自动保存是否存在问题? at February 09, 2012

    @cqpx 多谢你的解释。embeds_many 看来的场合更适合于解决关系数据库繁于处理的多层关联的问题。但又不是经常反复查询的数据. 不过,我想这正是 mongodb 对传统数据库的一个大的特点之一吧. 刚才的问题你的一些代码指引,我分析了觉得是一个 bug, 内部没有递归做 save 判定。给他们 mongoid 提一个 issues 先。

  • Mongoid 的 embedded_in 多层嵌入的自动保存是否存在问题? at February 09, 2012

    @Rei 不知道有人有这种用法没?我现在不太习惯 has_many, belongs_to 了,用文档设计模式的话这种应该较为常见吧。

  • Mongoid 的 embedded_in 多层嵌入的自动保存是否存在问题? at February 09, 2012

    @huacnlee 多谢。了解~

  • gem install 的时候默认跳过安装 ri 和 rdoc at February 04, 2012

    ri 跟 rdoc 在本地是用处太小了。没有智能解析. 实际上,安装了 rdoc 时,在本地使用 gem sever 可以在http://localhost:8808gem的api用浏览器查看相关,不过还是有些弱的。@fsword

  • 有没有好的开源项目,来收集目标网站的内容更新? at January 31, 2012

    看看是不是可以直接用 rss

  • 原来 ruby-china 也可以按 m 键了查看 markdown 语法了 at January 09, 2012

    bug: 连按几次就黑了显示不了了。浏览器:chrome16

  • rubygems.org 惊现 500 Error at January 02, 2012

    恢复了不过非常慢。

  • 大家有用 https 部署过网站么? at December 19, 2011

    网站证书需要签名网址,自我颁发的话可以随便填写。反正浏览器会警告

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