Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
贝尔斯
@beiersi
VIP
NO. 438 / 2011-12-10

3 Topics / 62 Replies
2 Followers
2 Following
32 Favorites
No GitHub.
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 学习 Ruby 的一些感慨,身虽远离,但心未存走远。 at August 28, 2016

    我只想问一个问题“未存走远”是嘛意思

  • Rails 有没有伪静态,有必要伪静态吗 at April 26, 2016
    default_url_options(opts = {})
      { format: 'html' }
    end
    
  • Rails 在页面循环输出的文字,怎么省略成。。。 at November 27, 2015

    http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-truncate

  • Redis 做缓存,fragment cache 如何缓存过期 at May 28, 2015

    方法一:可以根据数据库记录的变化来生成 cache_key,比如:

    <% cache @issues. maximum(:updated_at) do %>
      问题跟踪:(<%= @issues.count %>)
    <% end %>
    

    这种方法无法避免执行数据库查询,主要是减少 render 耗时,实现起来比较省事。

    方法二:使用 sweeper,在插入更新删除记录时强制 cache 过期。请参考 http://apidock.com/rails/ActionController/Caching/Sweeping

  • 花了几个周末做的图床,支持粘贴上传、拖放上传,支持自定义七牛空间 http://yotuku.cn at May 03, 2015

    :plus1:

  • git log 中%an: author name 和 $cd commitor date 有什么区别? at May 03, 2015

    如果你认真的查阅一下《pro git》中的相关章节就知道了,而且我觉得这个问题几乎毫无意义。

  • 安装和配置 Postfix at April 24, 2015

    #8 楼 @rei 可以试试 mailgraph ,图形监视。

  • 安装和配置 Postfix at April 24, 2015

    如果是新装的系统,推荐试试 iredmail,一键安装。什么 apache、postfix、mysql 或 postgresql、sasl、反垃圾、扫病毒、mailwebmail、web 管理等等一股脑都给装好了。 以前在 redhat 下给公司装过基于 qmail 的邮件系统,相当的麻烦。相比来说 iredmail 还是很省事的。

  • 有用 Spree Commerce 的吗?真心慢啊 at April 04, 2015

    #5 楼 @tini8 生产模式下启用了 cache 的,fragment cache。

  • 有用 Spree Commerce 的吗?真心慢啊 at April 04, 2015

    另外把 development 的 config.assets.debug 设为 false,也能提升一点速度。

  • 有用 Spree Commerce 的吗?真心慢啊 at April 04, 2015
    ### 开发模式
    Completed 200 OK in 2323ms (Views: 2284.9ms | ActiveRecord: 19.6ms)
    
    ###生产模式
    Completed 200 OK in 33ms (Views: 17.1ms | ActiveRecord: 7.2ms)
    

    这是我机器上同一个页面的在生产模式和开发模式下的速度差异。基本不用担心。

  • 报错:ExecJS::ProgramError in Products#index,求解决方法 at February 13, 2015

    #5 楼 @runup 可能是 nodejs 没有加入到 path 中导致的,你也可以在 Gemfile 中注释掉

    gem 'therubyracer', platforms: :ruby
    

    然后执行 bundle install

  • 报错:ExecJS::ProgramError in Products#index,求解决方法 at February 13, 2015

    #3 楼 @cysh windows 装 nodejs 不行么

  • Ruby 2.2 中的增量式垃圾回收 at February 13, 2015

    :plus1:

  • 报错:ExecJS::ProgramError in Products#index,求解决方法 at February 13, 2015

    其实遇到这种问题应该先 google,发到这里大部分人都懒得回复。

  • 报错:ExecJS::ProgramError in Products#index,求解决方法 at February 13, 2015

    没装 nodejs

  • 关于在 capistrano 的 deploy.rb 中 task 的问题 at October 19, 2014

    如果只针对于一个项目,自定义的 task 不多,直接写在 deploy.rb 里就行了。 简单来说 2 个步骤,1.创建自定义 task 2.自定义 task 插入已有的 task 流之中。

    举例:创建 database.yml 创建 database.yml 的 task 一般来说就是做一个符号链接,先准备好 database.yml 放在某个目录下: 然后增加一个 task,比如:

    # 增加一个自定义task
    task :link_database_config_file do
      on roles(:app) do
        execute :ln, '-s', 'your database config file path', "#{release_path}/config/database.yml"
      end
    end
    
    # 把自定义的task插入到task流中,这里我们把自定义的task插入到update task之前
    before :updated, 'deploy:link_database_config_file'
    
    #这样自定义的这个动作就会在task流执行到update之前执行
    

    想了解 task 执行的顺序参考:http://capistranorb.com/documentation/getting-started/flow/

    还有就是 capistrano-rails 这个 gem 已经包含了 db:migrate task 只要编辑 Capfile

    # 把这行注释去掉就行了
    require 'capistrano/rails/migrations'
    

    至于 db:create,只是第一次部署需要执行一次,手工完成就好了。

  • 如果设置通过 IP 地址访问不出现网站 at October 19, 2014

    专门建一个虚拟主机配置段,放到配置文件最前面,server name 设为 ip 或者任意,document_root 根据你想法设置,这样用 ip 地址直接访问就适配到这个虚拟主机了。apache 或者 nginx 都适用

  • bootstrap sass gem 的 precompile 真是无解... at October 19, 2014

    https://github.com/twbs/bootstrap-sass/ readme 里有这样一段话: Do not use //= require in Sass or your other stylesheets will not be able to access the Bootstrap mixins or variables.

    用法应该是: app/assets//stylesheets/application.scss

    /**
     *= require_self
     */
    
    @import "bootstrap-sprockets";
    @import "bootstrap";
    
  • 对 Rails 中「缓存失效」的一点疑惑 at October 04, 2014

    不好意思,之前回复有误(不适用于 rails 4),已删除 6 楼 @saiga 的回答是正确的。

  • 《Linux 命令行》中文版 PDF 上线了,epub 也上了 at October 04, 2014

    好书,值得仔细看 👍

  • 想问个问题,你们为何选择 Rails? at September 26, 2014

    #23 楼 @blacktulip 「当我看到搜索结果有 SO 的时候,第一反应是「哈哈,这下有救了」👍

  • 【低级问题】su -c 命令执行和直接执行的区别? at September 25, 2014

    有一个 rvmsudo 命令

  • 编写 Ruby 的 C 扩展 at September 24, 2014

    :thumbsup: :thumbsup: :thumbsup:

  • 请各位看看这是不是 Rails console 和 runner production 下的一个 bug at September 01, 2014

    我也有一次无意发现这个问题,我平时习惯是 rails c production,某天鬼使神差加了个-e 发现不对,也没深究,继续开心的 rails c production.

  • 今天我去面试, 受打击了 at September 01, 2014

    我觉得这题出得挺好的。。。 猜测楼主没有 phper 相关工作经验或者起手就用 php 框架,做这几道题有点吃亏。比如 5、12、13 题。

  • 我是来给大伙送航拍器的 at August 24, 2014

    😍

  • 如何让 Devise+Cancan 只能 admin 才能注册用户。 at July 24, 2014

    你可以自定义路由,也就是 不要定义 registrations#new 的路由。这样就永远无法访问到注册页面了。 由 admin 或者特定权限的用户创建新用户这个操作就是一个普通的 curd 的操作了,自己写一个 controll 就行了。 参考:https://github.com/plataformatec/devise/wiki/How-To:-Customize-routes-to-user-registration-pages

  • 请教如何拦截 url at April 18, 2014

    把原始的文件目录移动或改名,比如:mv public/files xxx; route 配置成以前的下载 url 形式,比如:get 'files/:filename' => 'files#download'

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