• 楼主写了很多东西,感谢楼主分享。

  • 文件结构如下

    但是当我用

    <img src="<%= image_url 'upload/CGImage封装.png' %>">
    

    直接报错

    ActionView::Template::Error (The asset "upload/CGImage封装.png" is not present in the asset pipeline.):
    

    我使用的是 production 模式运行的。

  • @embbnux view 层的代码

    <img src="<%= image_url 'CGImage封装.png' %>">
    

    生成的 HTML 如下

    <img src="http://static-assets-cdn.embbnux.com/assets/CGImage封装-HASH.png">
    

    因为目前没有真实 CDN 服务器,我就用的假的,production 模式

    config.action_controller.asset_host = Proc.new { |source|
      if source =~ /assets/
        'static-assets-cdn.embbnux.com'
      else
        'static-images-cdn.embbnux.com'
      end
    }
    

    成功生成链接,但是后面链接后面还是加上了 HASH。昨天不配置 asset_host 的时候直接报 ActionView::Template::Error,但是今天又没有问题,我还在探索问题。 ps:Ruby 社区真的很友善。

  • 请问楼主,我使用 image_url 并不能自动识别是否加 hash,出现错误

    ActionView::Template::Error (The asset "upload/CGImage封装.png" is not present in the asset pipeline.):
    

    我在 public/upload 目录下有 CGImage 封装.png 文件,我使用的时 production 模式运行的。

  • Rails 中消失的 CSRF token at 2017年06月02日

    @warmwind 我有一个疑问,当打开多个页面的时候,rails 会生成不同的 authenticity_token,那么不同页面的 authenticity_token 不同,当 rails 验证的时候会用最后产生的 authenticity_token 验证,还是每个页面的验证都是没有问题的?

  • 為你自己學 Ruby on Rails at 2017年05月31日

    我是在工作中学习 Ruby on Rails,不过这样学习真的会遗漏很多知识,楼主的教程真不错

  • 使用 Rails 构建 API 实践 at 2016年06月29日

    #177 楼 @kayakjiang 不好意思,之前有事现在才看到。确实是我写的有问题,我用的不是before_create,而是before_save。谢谢这么仔细解答我的问题。

  • 使用 Rails 构建 API 实践 at 2016年06月17日

    每次update_attributes之后都会更新authenticaton_token。更新属性后就又要获取一遍authentication_tokne,是不是太麻烦了。有没有方法可以避免这种情况?

  • Shell 备份目录问题 at 2016年06月07日

    你可以使用 Capistrano 这个 Gem 包,可以设置链接文件,部署的时候,提前在服务器创建这些文件,cap 会自动帮你链接上

    # Default value for :linked_files is []
    set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
    # shared/config/database.yml
    
    # Default value for linked_dirs is []
    set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system')
    
  • 使用 Rails 构建 API 实践 at 2016年04月09日
    if @user && @user.authenticate(create_params[:password])
    

    authenticate 方法是 bcrypt 这个 gem 包中的方法吗?谢谢解答

  • 使用 Rails 构建 API 实践 at 2016年03月29日

    #134 楼 @kayakjiang 谢谢回复,我确实是用的浏览器访问的。

  • 使用 Rails 构建 API 实践 at 2016年03月28日

    ##出错,我在 app/views/api/v1/users 目录下新建了 show.json.builder 文件,

    Missing template api/v1/users/show, api/v1/base/show, application/show with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in: * "/root/build-an-api-rails-demo/app/views"
    

    请教下问题出在哪?