diff --git a/app/assets/javascripts/main.js.erb b/app/assets/javascripts/main.js.erb new file mode 100644 index 0000000..02b7a7f --- /dev/null +++ b/app/assets/javascripts/main.js.erb @@ -0,0 +1,7 @@ +// This is a manifest file that'll be compiled into including all the files listed below. +// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically +// be included in the compiled file accessible from http://example.com/assets/application.js +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// the compiled file. +// +//= require_tree . diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 76a0bcc..d009094 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -9,7 +9,6 @@ = javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js" = javascript_include_tag "https://github.com/scottschiller/Snowstorm/raw/master/snowstorm-min.js" = javascript_include_tag "application" - = javascript_include_tag "analytics" = csrf_meta_tag %meta{:name => "viewport", :content => "initial-scale=1.0, user-scalable=no"} %body diff --git a/config/application.rb b/config/application.rb index 0035c22..7ae4915 100644 --- a/config/application.rb +++ b/config/application.rb @@ -2,10 +2,12 @@ require File.expand_path('../boot', __FILE__) require 'rails/all' -# If you have a Gemfile, require the default gems, the ones in the -# current environment and also include :assets gems if in development -# or test environments. -Bundler.require *Rails.groups(:assets) if defined?(Bundler) +if defined?(Bundler) + # If you precompile assets before deploying to production, use this line + Bundler.require *Rails.groups(:assets => %w(development test)) + # If you want your assets lazily compiled in production, use this line + # Bundler.require(:default, :assets, Rails.env) +end module AdoptAHydrant class Application < Rails::Application @@ -39,5 +41,8 @@ module AdoptAHydrant # Enable the asset pipeline config.assets.enabled = true + + # Version of your assets, change this if you want to expire all your assets + config.assets.version = '1.0' end end diff --git a/config/environments/development.rb b/config/environments/development.rb index 9b0292c..90894d3 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -25,4 +25,7 @@ AdoptAHydrant::Application.configure do # Do not compress assets config.assets.compress = false + + # Expands the lines which load the assets + config.assets.debug = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index e6b75f7..c8b3d76 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -9,14 +9,23 @@ AdoptAHydrant::Application.configure do config.action_controller.perform_caching = true # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = true + config.serve_static_assets = false # Compress JavaScripts and CSS config.assets.compress = true + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = false + + # Generate digests for assets URLs + config.assets.digest = true + + # Defaults to Rails.root.join("public/assets") + # config.assets.manifest = YOUR_PATH + # Specifies the header that your server uses for sending files - # (comment out if your front-end server doesn't support this) - config.action_dispatch.x_sendfile_header = nil # Use 'X-Accel-Redirect' for nginx + # 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 diff --git a/config/environments/test.rb b/config/environments/test.rb index 6718b70..7f91921 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -37,4 +37,7 @@ AdoptAHydrant::Application.configure do # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + + # Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets + config.assets.allow_debugging = true end diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 71b88b0..da4fb07 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -4,9 +4,11 @@ # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. -ActionController::Base.wrap_parameters :format => [:json] +ActiveSupport.on_load(:action_controller) do + wrap_parameters :format => [:json] +end # Disable root element in JSON by default. -if defined?(ActiveRecord) - ActiveRecord::Base.include_root_in_json = false +ActiveSupport.on_load(:active_record) do + self.include_root_in_json = false end diff --git a/test/test_helper.rb b/test/test_helper.rb index 8153f71..8899bba 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,6 +1,6 @@ +ENV["RAILS_ENV"] = "test" require 'simplecov' SimpleCov.start 'rails' -ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' require 'webmock/test_unit'