Rails 5.0
This commit is contained in:
parent
2892d5272d
commit
2557645f4f
25 changed files with 367 additions and 186 deletions
8
config/initializers/application_controller_renderer.rb
Normal file
8
config/initializers/application_controller_renderer.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# ActiveSupport::Reloader.to_prepare do
|
||||
# ApplicationController.renderer.defaults.merge!(
|
||||
# http_host: 'example.org',
|
||||
# https: false
|
||||
# )
|
||||
# end
|
||||
11
config/initializers/assets.rb
Normal file
11
config/initializers/assets.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Version of your assets, change this if you want to expire all your assets.
|
||||
Rails.application.config.assets.version = '1.0'
|
||||
|
||||
# Add additional assets to the asset load path
|
||||
# Rails.application.config.assets.paths << Emoji.images_path
|
||||
|
||||
# Precompile additional assets.
|
||||
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
||||
# Rails.application.config.assets.precompile += %w( search.js )
|
||||
5
config/initializers/cookies_serializer.rb
Normal file
5
config/initializers/cookies_serializer.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Specify a serializer for the signed and encrypted cookie jars.
|
||||
# Valid options are :json, :marshal, and :hybrid.
|
||||
Rails.application.config.action_dispatch.cookies_serializer = :marshal
|
||||
|
|
@ -2,4 +2,3 @@
|
|||
|
||||
# Add new mime types for use in respond_to blocks:
|
||||
# Mime::Type.register "text/richtext", :rtf
|
||||
# Mime::Type.register_alias "text/html", :iphone
|
||||
|
|
|
|||
20
config/initializers/new_framework_defaults.rb
Normal file
20
config/initializers/new_framework_defaults.rb
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
#
|
||||
# This file contains migration options to ease your Rails 5.0 upgrade.
|
||||
#
|
||||
# Once upgraded flip defaults one by one to migrate to the new default.
|
||||
#
|
||||
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
|
||||
|
||||
# Enable per-form CSRF tokens. Previous versions had false.
|
||||
Rails.application.config.action_controller.per_form_csrf_tokens = false
|
||||
|
||||
# Enable origin-checking CSRF mitigation. Previous versions had false.
|
||||
Rails.application.config.action_controller.forgery_protection_origin_check = false
|
||||
|
||||
# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
|
||||
# Previous versions had false.
|
||||
ActiveSupport.to_time_preserves_timezone = false
|
||||
|
||||
# Require `belongs_to` associations by default. Previous versions had false.
|
||||
Rails.application.config.active_record.belongs_to_required_by_default = false
|
||||
|
|
@ -5,21 +5,20 @@ module ActionDispatch
|
|||
class SlugCookieStore < CookieStore
|
||||
alias_method :orig_set_cookie, :set_cookie
|
||||
|
||||
def set_cookie(env, session_id, cookie)
|
||||
def set_cookie(request, session_id, cookie)
|
||||
if script_name = FoodsoftConfig[:script_name]
|
||||
request = ActionDispatch::Request.new env
|
||||
path = request.original_fullpath[script_name.size..-1]
|
||||
slug = path.split('/', 2).first
|
||||
return if slug.blank?
|
||||
cookie[:path] = script_name + slug
|
||||
end
|
||||
orig_set_cookie env, session_id, cookie
|
||||
orig_set_cookie request, session_id, cookie
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Foodsoft::Application.config.session_store :slug_cookie_store, key: '_foodsoft_session'
|
||||
Rails.application.config.session_store :slug_cookie_store, key: '_foodsoft_session'
|
||||
|
||||
# Use the database for sessions instead of the cookie-based default,
|
||||
# which shouldn't be used to store highly confidential information
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
||||
wrap_parameters format: [:json]
|
||||
end
|
||||
|
||||
# To enable root element in JSON for ActiveRecord objects.
|
||||
# ActiveSupport.on_load(:active_record) do
|
||||
# self.include_root_in_json = true
|
||||
# self.include_root_in_json = true
|
||||
# end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue