Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
@zhangjingqiang
高级会员
第 592 位会员 / 2011-12-26

北京
17 篇帖子 / 95 条回帖
3 关注者
0 正在关注
35 收藏
GitHub Public Repos
  • it123 2

  • terminal 0

  • awesome-projects 0

  • timecard 0

  • dotfiles 0

  • BlogAI 0

  • ChatGPT 0

  • random 0

  • editor 0

  • zhangjingqiang.github.io 0

More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • 除夕夜你还看春晚? at 2013年02月08日

    #10 楼 @ashchan 下周一晚 Sky Tree 有什么特别活动吗?

  • 给 Ruby China 换装 -> Ruby China on Heroku at 2013年02月08日

    #3 楼 @460411234 Heroku 部署真正的 Ruby China 我也不会😁

  • 给 Ruby China 换装 -> Ruby China on Heroku at 2012年12月21日

    嗯,有的主题还行,有的确实勉强。这是 Bootswatch 主题随机的。

  • 需要一些 ruby on rails 大牛在 g+ 或者 twitter 上的账号 at 2012年10月13日

    http://ihower.tw/rails3/ecosystem.html

    @ihower 总结的 Ruby on Rails 生态圈

  • 开源扑克挺好玩,你订购了吗? at 2012年09月13日

    只是觉得这种开源汇总的创意挺好,要说价钱,怎能和当年 Ubuntu 免费全球发 CD 的大气比呢:D

  • 有人实现这个,付费。 at 2012年08月23日

    #8 楼 @ttsaon 在 facebook 上没收到你的消息呀。 twitter: @zhangjingqiang

  • 有人实现这个,付费。 at 2012年08月22日

    #6 楼 @ttsaon 你先参考一下这个吧: https://github.com/zhangjingqiang/facebook-ruby/blob/master/app.rb

    这是较旧的一个版本,使用mogli,现在创建 facebook 应用时给的是koala的例子。

    可以这样联系我: http://fb.com/zhangjingqiang

  • 有人实现这个,付费。 at 2012年08月22日

    facebook 的应用我开发很多。

    Javascript

    JavaScript SDK

    PHP

    facebook-php-sdk

    Ruby

    Koala

    顺便做下广告: 这是我一周内开发的应用(PHP),在日本地区每月活跃用户两万人: facebook 战斗力鉴定 APP 这是我一个月内开发的应用集(Ruby),几乎把所有社交媒体做个遍。尚未完全公开: facebook 应用集

  • 好吧,实在搞不出来.devise (2.1.2)+omniauth (1.1.0) at 2012年08月15日

    #7 楼 @jialezhang 这个例子是这样处理的: app/models/user.rb

    def self.find_for_facebook_oauth(access_token, signed_in_resource=nil)
      data = access_token.extra.raw_info
      if user = self.find_by_email(data.email)
        user
      else # Create a user with a stub password.
        self.create!(:email => data.email, :password => Devise.friendly_token[0,20])
      end
    end
    

    app/controllers/users/omniauth_callbacks_controller.rb

    def facebook
      # You need to implement the method below in your model
      @user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)
    
      if @user.persisted?
        flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook"
        sign_in_and_redirect @user, :event => :authentication
      else
        session["devise.facebook_data"] = request.env["omniauth.auth"]
        redirect_to new_user_registration_url
      end
    end
    

    写共通方法的我没试过,但这个例子很好(twitter+facebook+google): /app/models/user.rb

    class User < ActiveRecord::Base
      def self.from_omniauth(auth)
        find_by_provider_and_uid(auth["provider"], auth["uid"]) || create_with_omniauth(auth)
      end
    
      def self.create_with_omniauth(auth)
        create! do |user|
          user.provider = auth["provider"]
          user.uid = auth["uid"]
          user.name = auth["info"]["name"]
        end
      end
    end
    

    /app/controllers/sessions_controller.rb

    def create
      user = User.from_omniauth(env["omniauth.auth"])
      session[:user_id] = user.id
      redirect_to root_url, notice: "Signed in!"
    end
    

    (来自:http://railscasts.com/episodes/304-omniauth-identity?view=asciicast)

  • 好吧,实在搞不出来.devise (2.1.2)+omniauth (1.1.0) at 2012年08月14日

    http://zhangjingqiang.tumblr.com/post/28318572989/mongodb-devise-omniauth-cancan

    这个参考一下吧,facebook 的例子,原理一样。

  • omniauth facebook 求助 at 2012年08月14日

    确保你在 facebook app 中填入的 url 和你实际程序的 url 一致。比如开发环境和产品环境不同,端口号也要注意。这点 twitter 要宽松些。

  • which is best? at 2012年08月09日
    • name
    • username
    • nickname
    • first_name
    • last_name

    等都有不同的含义,优雅地讲不能随便取一个就算了的。 就单独记录一个用户的名称的话,推荐用 name 参考 omniauth-identity 以及其 RailsCast 。

  • Ckeditor 报 CanCan::AuthorizationNotPerformed in Ckeditor::PicturesController#index at 2012年06月26日
    • Callbacks ```ruby class ApplicationController < ActionController::Base

    protected

    # Cancan example def ckeditor_authenticate authorize! action_name, @asset end

    # Set current_user as assetable def ckeditor_before_create_asset(asset) asset.assetable = current_user return true end end

    * `cancan` 参照 [wiki](https://github.com/ryanb/cancan/wiki/Defining-Abilities) 
    
  • Rails 服务启动的判定方法 at 2012年06月05日

    用 Module.const_defined? 可以确认 rails console 启动时加载的定没定义的类。

    # 在 rails console 使用 irb 的时候
    Module.const_defined? :IRB
    # 在 rails console 使用 pry 的时候
    Module.const_defined? :Pry
    

    这样 rails console 执行时返回 true,rails server 执行时返回 false ,可以判定。

  • Rails 服务启动的判定方法 at 2012年06月05日

    提问者把问题补充了,我简单翻译一下:

    现在在表中设置了动态的检测员作为监视对象,但是想排除 rails console 的时候监视对象。

    # Migration
    class CreateObserveTable < ActiveRecord::Migration
     def self.up
      create_table observe_tables do |t|
       t.string :table_name
      end
     end
    end
    
    # Fixture
    ObserveTable.create{ :table_name => "users"}
    ObserveTable.create{ :table_name => "user_profiles"}
    
    # Observer
    class OperationLogObserver < ActiveRecord::Observer
    
     if 只想在从服务器启动时执行
      observe ObserveTable.all.map{|table| table.table_name.classify.to_sym}
     end
    
     def after_save
      #do something
     end
    
    end
    

    现知道这样的判定方法

    if defined?(Mongrel) or defined?(WEBrick)
      # 作为服务器的处理
    else
      # 作为一个脚本处理
    end
    

    但用Passenger时,这样的做法并不起效

    defined?(Passenger)
    

    找好方法。

  • Rails 服务启动的判定方法 at 2012年06月05日

    我想这个问题的意思是:

    如果执行了 rails server rails console 的操作,从哪里可以判断执行了。

  • rails 在开发多频道网站的时候怎么布局 app? at 2012年04月27日

    建的时候分层,然后在 routing 里自由映射。

  • 62 个 Ruby On Rails 学习资源整理 at 2012年04月27日

    今天也列出一个资源,数量比这是少多了。

    http://rubyistonrails.tumblr.com/post/21908893405/ruby-on-rails

    PS:那不是本人的主 Tumblr 博客,今天为了弄个 Ruby on Rails 列表单开的一个:)

  • social-share-button - 分享功能 at 2012年04月19日

    @huacnlee 再增加一个可以自定义 URL 的判断就更好了。 文件:social-share-button.coffee

    window.SocialShareButton =
      ...
      share : (site, title) ->
        url = encodeURIComponent(location.href)
        title = encodeURIComponent(title)
        ...
        false
    
    

    的share : (site, title) ->中加上url参数,参数为空时用location.href。 这样更灵活。期待下一版本中加入。

  • 大家发邮件一般用哪个 gem? at 2012年04月17日

    用 Rails 的话,有专门的 Action Mailer。 http://guides.rubyonrails.org/action_mailer_basics.html#sending-emails-with-attachments

  • rails 里面怎么判断两次输入的密码是否一致? at 2012年04月17日
    validates :password, presence: { on: :create}, confirmation: { allow_blank: true }, length:{maximum:20,minimum:6}
    
    
  • ruby-china install 出错,求指点。 at 2012年04月05日

    在 Gemfile 里添加两行

    gem 'execjs'
    gem 'therubyracer'
    
    

    再次执行。

  • 日本女人的 Rubyist at 2012年03月30日

    看了个人资料页,佩服得不得了。 模特 + 技术者 + 大学生,堪称完美。 喜欢的话竟然是“拉面”。

    我旁边的日本人说 義塾 这样的大学有很多优秀的学生。 很多日本技术者也都想和她一起开发项目呢:XD

    另外, http://fb.dev-plus.jp 这个网站不错,也是一个重要的信息。

  • 有开源的网址导航产品么? at 2012年03月26日

    http://www.kaifazhe.com/

    这个自称世界上最美的导航,居然无视 Ruby!

  • 发点牢骚! 真的觉得日本人好牛~~ at 2012年03月24日

    #19 楼 @AlphaLiu 日本是有很多优秀的技术书,尤其是 Ruby 原创经典。特点是详细,图文并茂。有时会插漫画形式,的确很有价值。但他们传往国外的很少.不单是在中国难见,在美国也难见。

    #20 楼 @fenprace 是呀,在中国搞 IT 的跟日本沾边的,全靠 Ruby 了吧?(这里不谈对日外包)

  • 发点牢骚! 真的觉得日本人好牛~~ at 2012年03月24日

    #16 楼 @dreamrise Yasuhiro Matsumoto http://mattn.github.com/zencoding-vim/

  • 你们是不是也是开一堆 shell. at 2012年03月24日

    装 rails.vim 的话,用:RV 或:RS 分屏挺好,可以对照。

  • 发点牢骚! 真的觉得日本人好牛~~ at 2012年03月24日

    #12 楼 @zw963 是比较多。他们对这类技术的普及要比中国多,毕竟中国在“墙内”,限制了很多技术的发展。这是目前两本很好的书。 Emacs Vim

  • 发点牢骚! 真的觉得日本人好牛~~ at 2012年03月24日

    #10 楼 @zw963 呵呵,我在日本很多年了。身临其境了解了很多。

  • 发点牢骚! 真的觉得日本人好牛~~ at 2012年03月24日

    日本人的专心程度、精益求精的精神的确是世界上数一数二的。 在日本的大小书店里,很多貌似古老的工具书却翻新几版来出版。Vim、Emacs 之类最近又有新书(150 技)发行。 他们做事很专一,做一件事是要有始有终的。 但整体感觉似乎没有中国人快乐。压力产生压抑。 所以,各有好处坏处。

    从软件的角度说,我们做的精细度不如他们,可以在量上拼一拼。用他们的话说,中国分母大。

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