rails小贴士

  • 让cookie对子域名也管用,customized session cookie domain
  • #production.rb
    if config.action_controller.session
      config.action_controller.session[:domain] = '.example.com'
    else
      config.action_controller.session = { :domain => '.example.com' }
    end
    
  • 配置javascript/image/css 等路径
  • #production.rb
    ActionController::Base.asset_host = "assets.example.com"
    

    <%=javascript_include_tag "jquery"%>
    就会生成 <script src="http://assets.example.com/javascripts/jquery.js?1251861242" type="text/javascript"></script>
  • 从yml中load配置参数
  • #config/test.yml
    development:
      access_key: afasfasdsa
      secret_key: 5/W9zw
    test:
      access_key: afasfasdsa
      secret_key: 5/W9zw
    production:
      access_key: afasfasdsa
      secret_key: 5/W9zw
    

    load from initializer
    #config/initializers/app_config.rb
    TEST_CONFIG = YAML.load_file(File.join(Rails.root, "config", "test.yml"))[RAILS_ENV].symbolize_keys
    

    你可能感兴趣的:(JavaScript,jquery,Access,Ruby,Rails)