Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
Rei
@Rei
管理员
第 1 位会员 / 2011-10-28

[email protected]
深圳
182 篇帖子 / 9132 条回帖
727 关注者
0 正在关注
11 收藏
中下水平 Rails 程序员
打赏作者
GitHub Public Repos
  • writings 940

    [Closed] Source code of writings.io

  • alipay 732

    Unofficial alipay ruby gem

  • code_campo 291

    [Closed] Source code of http://codecampo.com

  • asciidoctor-pdf-cjk-ka... 101

    **no longer maintained**

  • asciidoctor-htmlbook 31

    Asciidoctor HTMLBook is an Asciidoctor backend for converting AsciiDoc documents to HTMLBook docu...

  • material-ui 17

  • rich-text-editor 12

  • htmlrenderer 12

  • rails-chatgpt-demo 8

  • rails-app 7

    A Rails project template lets me start new projects quickly.

More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • [解決] 用 Capistrano 部署, assets 的文件名對不上是怎麼回事呢... at 2013年03月14日

    #6 楼 @blacktulip 带根目录 / 就不预处理,不带就预处理,扩展成 assets 编译后的名字。

  • [解決] 用 Capistrano 部署, assets 的文件名對不上是怎麼回事呢... at 2013年03月14日

    image_tag("logo.png")

  • Google Reader 即将关闭,你有什么想说的? at 2013年03月14日

    关得太早了,自己没发展出一个替代方案。不过这也就把市场让给别人了。

  • 使用 Go 代替 Ruby 将服务器数量从 30 降到 2 at 2013年03月14日

    Iron.io 打开网站看,IronMQ is the Message Queue for the Cloud,这不是 Rails 的应用场合了,把主要部分用其他对异步/并发支持更好的语言重写是正常的。

    Erlang 看过一点,函数式语言给我不少启发,不过在 web 这样的应用场合,不想用这种思考模式来编程。需要性能和并发一类的任务,我也会选 go,语法更易理解。

  • writings.io - 提供在线文章写作、管理、发布的网站服务 at 2013年03月13日

    #79 楼 @gazeldx 给个截图?

  • ruby-china 发表帖子的功能一些问题? at 2013年03月12日

    #9 楼 @zjnxzy Gemfile 里面找到这个

    # Markdown 格式
    gem "redcarpet", "~> 2.2.2"
    

    调用地方在这里

    https://github.com/ruby-china/ruby-china/blob/master/app/models/mongoid/markdown_body.rb#L13

    然后这个模块被 Topic 和 Replay 引入。

    我都有点晕,哈哈。

  • ruby-china 发表帖子的功能一些问题? at 2013年03月12日

    #6 楼 @zjnxzy 这是 Markdown 语法,服务端会进行解析。

  • ruby-china 发表帖子的功能一些问题? at 2013年03月12日

    https://github.com/ruby-china/ruby-china/blob/master/app/assets/javascripts/topics.coffee#L18

  • rails 线上环境标配是什么? at 2013年03月12日

    #14 楼 @HungYuHei Passenger 普通版不支持,我打算用户量上去之后买企业版。

  • rails 线上环境标配是什么? at 2013年03月12日

    #11 楼 @mistbow 我一直用 Passenger

  • rails 线上环境标配是什么? at 2013年03月12日

    passenger 特点就是简单。

  • 做开发到底是 Linux 好 还是 Mac 好? at 2013年03月12日

    #99 楼 @quakewang 获得成就:审美偏差。

    只要购买苹果产品,就会自动获得前所未有的审美能力和开启 Think different 技能,赶紧拨打电话订购吧!

  • 关于 ActiveRecord 如何提取一个字段? at 2013年03月12日

    #6 楼 @topswim 3 楼会爆内存,你的想法是对的

  • 做开发到底是 Linux 好 还是 Mac 好? at 2013年03月12日

    #97 楼 @jan 表示中枪

  • writings.io - 提供在线文章写作、管理、发布的网站服务 at 2013年03月12日

    #72 楼 @dreamable 打算部分组件开源,通用的才会作成 Gem。

    #73 楼 @zhangyi2099

    nginx 里面

    server {
      listen 80 default_server;
      ...
    }
    

    让所有域名都指向这个 Rails app,然后路由里面做判断,将二级域名或者其他域名指向 Site 模块下的 Controller

    class Sitedomain
      def matches?(request)
        request.host =~ /^\w+\.writings.io$/ or request.host !~ /writings.io$/ # 刚发现这里一个 != 'writings.io' 就完事了,可以简化。为了方便开发时候测试,writings.io 这个域名最好替换成不同开发环境的常量,或者放到统一的配置文件里面,我目前用配置文件。
      end
    end
    
    constraints(Sitedomain) do
      scope :module => 'site', :as => 'site' do
        root :to => 'articles#index'
        ...
      end
    end
    

    Site 模块下的 Controller 继承一个 Site::BaseConroller,前置过滤器确定要显示的子站

    class Site::BaseController < ApplicationController
      layout 'site'
      before_filter :require_site
    
      private
    
      def require_site
        if request.host =~ /^\w+\.writings.io$/
          # 二级域名
          @user = User.find_by(:name => /^#{request.subdomain(2)}$/i)
    
          redirect_to url_for(:host => @user.domain) if @user.domain.present? # 已经设置独立域名则跳到独立域名
        else
          # 个人域名
          @user = User.find_by(:domain => request.host)
        end
      end
    end
    

    然后 Site 模块下的控制器处理的都是 @user 这个用户的数据。

  • 如果把 Ruby China 的回帖改成 Nested 咋样? at 2013年03月12日

    #26 楼 @linjunpop 好文章

  • 如果把 Ruby China 的回帖改成 Nested 咋样? at 2013年03月11日

    这样的坏处就是没人会“跟帖”,都会 reply 尽量靠上的那个人。

  • 如果把 Ruby China 的回帖改成 Nested 咋样? at 2013年03月11日

    不要。很难看,现在的 #楼层效果很好。

  • 表单的一个细节问题 at 2013年03月11日

    http://twitter.github.com/bootstrap/

  • 表单的一个细节问题 at 2013年03月11日

    要补 CSS 知识。

  • 表单的一个细节问题 at 2013年03月11日

    #2 楼 @jokerjiang application.css 里面加这行

    label {
      display: inline;
    }
    
  • 表单的一个细节问题 at 2013年03月11日

    css

  • 有什么工具可以方便构建数据库表? at 2013年03月11日

    rake db:schema:dump

  • 请教关于 assets 如何只包含必要的 js at 2013年03月10日

    预编译哪个 js 是要设置的,在 config/environments/production.rb 里面

    config.assets.precompile += %w( dashboard.js editor.js site.js )
    

    dashboard layout 里面引用

    = javascript_include_tag "dashboard"
    
  • 请教关于 assets 如何只包含必要的 js at 2013年03月10日

    如果再加上 Turbolink 可能更难理解了。

  • 请教关于 assets 如何只包含必要的 js at 2013年03月10日

    js 全部打包在一起,怎么区分不同 action 的逻辑

    if ($('body#articles-edit').length) {
      // code for ArticlesController#edit
    }
    

    layout

    body id=("#{controller_name}-#{action_name}")
    
  • 请教关于 assets 如何只包含必要的 js at 2013年03月10日

    给个实例

    ▾ app/
      ▾ assets/
        ▸ images/
        ▾ javascripts/
          ▾ dashboard/
            ▸ accounts/
            ▾ articles/
                edit.js
                index.js
            ▸ books/
            ▸ profiles/
          ▸ editor/
          ▾ sitewide/
              alert_messages.js
              dropdown.js
              highlight.js
              jquery.cookie.js
              modal.js
              page_ready.js
              rails.validations.js
            dashboard.js
            editor.js
            site.js
    

    预编译顶层的三个 js,dashboard.js, editor.js, site.js,分别对应三个 layout,每个 layout link 一个 js。

    dashboard.js 的头

    //= require jquery
    //= require jquery_ujs
    //= require turbolinks
    //= require mousetrap
    //= require_tree ./sitewide
    //= require_tree ./dashboard
    

    sitewide 本来打算放全局都要用的 js,后来发现里面有些 js 也不是全局需要的,改名 lib 更好。

  • 请教关于 assets 如何只包含必要的 js at 2013年03月10日

    http://railsapps.github.com/rails-javascript-include-external.html

  • writings.io - 提供在线文章写作、管理、发布的网站服务 at 2013年03月10日

    #63 楼 @hlcfan 用户名那栏在失去焦点时会 ajax 检查唯一性卡顿一下,我先记下以后加个检查提示。

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