Rails 5.0

This commit is contained in:
Patrick Gansterer 2020-09-04 12:57:19 +02:00
parent 2892d5272d
commit 2557645f4f
25 changed files with 367 additions and 186 deletions

View 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

View 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 )

View 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

View file

@ -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

View 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

View file

@ -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

View file

@ -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