• #5 楼 @metal 确实是没有

    bundle exec rake assets:precompile RAILS_ENV= production
    

    的问题

    虽然 openshift 的提示了

    remote: Precompiling with 'bundle exec rake assets:precompile'
    

    但是似乎它没有正确工作,当我在.openshift/action_hooks/deploy 的文件中增加

    bundle exec rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
    

    重新上传,application.css 工作正常。

  • #4 楼 @metal

    还没有试,刚好有这个想法。

    在本地执行 rake assets:precompile 又可以正确生成哦,只是上传到 openshift 的时候没有生成,这是让人困惑的地方。

  • #1 楼 @metal 上传到 openshift 的时候,显示已经执行

    remote: Precompiling with 'bundle exec rake assets:precompile'
    

    而且同目录下的 home.scss 已经正确生成 home.css

  • 不确定是否跟 production.rb 有关不,这里也贴一下

    cat config/environments/production.rb

    RailsApp::Application.configure do
      # Settings specified here will take precedence over those in config/application.rb
    
      # Code is not reloaded between requests
      config.cache_classes = true
    
      # Full error reports are disabled and caching is turned on
      config.consider_all_requests_local       = false
      config.action_controller.perform_caching = true
    
      # Disable Rails's static asset server (Apache or nginx will already do this)
      config.serve_static_assets = true
    
      # Compress JavaScripts and CSS
      config.assets.compress = true
    
      # Don't fallback to assets pipeline if a precompiled asset is missed
      # config.assets.compile = true
      config.assets.compile = true
    
      # Generate digests for assets URLs
      config.assets.digest = false
    
      # Defaults to nil and saved in location specified by config.assets.prefix
      # config.assets.manifest = YOUR_PATH
    
      # Specifies the header that your server uses for sending files
      # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
      # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
    
      # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
      # config.force_ssl = true
    
      # See everything in the log (default is :info)
      # config.log_level = :debug
    
      # Prepend all log lines with the following tags
      # config.log_tags = [ :subdomain, :uuid ]
    
      # Use a different logger for distributed setups
      # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
    
      # Use a different cache store in production
      # config.cache_store = :mem_cache_store
    
      # Enable serving of images, stylesheets, and JavaScripts from an asset server
      # config.action_controller.asset_host = "http://assets.example.com"
    
      # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
      # config.assets.precompile += %w( search.js )
      # config.assets.precompile += ["*.js", "*.css"]
    
      # Disable delivery errors, bad email addresses will be ignored
      # config.action_mailer.raise_delivery_errors = false
    
      # Enable threaded mode
      # config.threadsafe!
    
      # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
      # the I18n.default_locale when a translation can not be found)
      config.i18n.fallbacks = true
    
      # Send deprecation notices to registered listeners
      config.active_support.deprecation = :notify
    
      # Log the query plan for queries taking more than this (works
      # with SQLite, MySQL, and PostgreSQL)
      # config.active_record.auto_explain_threshold_in_seconds = 0.5
    end
    
  • 招远程办公的不?

  • #19 楼 @chenge 同意!

  • #10 楼 @neverlandxy_naix 第一次打开页面,得到的 object_id 是 33495240 第二次刷新页面,得到的 object_id 是 35038600

    呵呵,有啥优化方法?

    #9 楼 @chenge 有没有具体点的?

  • 我使用了 helper 方法来实现本帖提到的这些需求

    def site_conf(key)
      @conf ||= YAML.load_file("#{Rails.root}/config/site.yml")
      @conf[key]
    end
    

    这样,我在页面 HAML 模板中就可以这样使用了

    %h1= link_to site_conf('title'), root_url
    

    我的 YAML 文件 site.yml

    title: i'm a ruby bird
    

    现在基本能工作了,单还是有一个问题,就是 每次调用 site_conf,是不是就直接返回@conf了? 我知道

    @conf ||= YAML.load_file("#{Rails.root}/config/site.yml")
    

    是有定义就返回@conf,没有就执行后一句

    但是 ruby 的变量有作用域,第一调用 site_conf 获得的@conf,再第二次调用是否依然可用??

  • #1 楼 @iBachue 好主意

  • #4 楼 @sevk 这个方法看起来比较优雅

  • 问题已经解决,谢谢各位。就是在 model 中删除可注册选项即可。

  • 参考这个:http://stackoverflow.com/questions/9480741/what-variable-should-i-place-in-this-form-to-edit-a-comment-rails

    把 app/views/comments/_form.html.haml 改为

    = form_for([@post, @comments]) do |f| 
      .field
        = f.label :commenter
        %br/
        = f.text_field :commenter
      .field
        = f.label :body 
        %br/
        = f.text_area :body
      .actions
        = f.submit 
    

    然后在 app/controllers/posts_controller.rb 的 show 中添加

    @comments = @post.comments.build
    

    在 app/controllers/comments_controller.rb 的 edit 中修改如下

    def edit
      @post = Post.find(params[:post_id])
      @comments = @post.comments.find(params[:id])
    end
    

    现在可以编辑了,感谢大家

  • 刚刚看到了删除的功能,但是在 post 下编辑 conmment,还是没有发现