-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #362 from cubesystems/rails61
Rails 6.1, Ruby 2.7 support
- Loading branch information
Showing
30 changed files
with
188 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ dist: bionic | |
language: ruby | ||
cache: bundler | ||
rvm: | ||
- 2.6 | ||
- 2.7 | ||
|
||
addons: | ||
apt: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ruby=ruby-2.6 | ||
ruby=ruby-2.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
releaf-core/app/lib/releaf/responders/feature_disabled_responder.rb
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
releaf-core/app/views/releaf/error_pages/access_denied.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
= render 'releaf/error_pages/error', message: t('You are not authorized to access %{controller}', controller: controller_name, default: 'You are not authorized to access %{controller}', scope: controller_scope_name) | ||
= render 'releaf/error_pages/error', message: t('You are not authorized to view this page', scope: controller_scope_name) |
1 change: 0 additions & 1 deletion
1
releaf-core/app/views/releaf/error_pages/feature_disabled.html.haml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
require 'globalize' | ||
|
||
module Globalize::Accessors | ||
def globalize_accessors(options = {}) | ||
options.reverse_merge!(:locales => I18n.available_locales, :attributes => translated_attribute_names) | ||
class_attribute :globalize_locales, :globalize_attribute_names, :instance_writer => false | ||
|
||
self.globalize_locales = options[:locales] | ||
self.globalize_attribute_names = [] | ||
|
||
each_attribute_and_locale(options) do |attr_name, locale| | ||
define_accessors(attr_name, locale) | ||
end | ||
|
||
include InstanceMethods | ||
end | ||
|
||
def localized_attr_name_for(attr_name, locale) | ||
"#{attr_name}_#{locale.to_s.underscore}" | ||
end | ||
|
||
private | ||
|
||
def define_accessors(attr_name, locale) | ||
define_getter(attr_name, locale) | ||
define_setter(attr_name, locale) | ||
end | ||
|
||
def define_getter(attr_name, locale) | ||
define_method localized_attr_name_for(attr_name, locale) do | ||
globalize.stash.contains?(locale, attr_name) ? globalize.send(:fetch_stash, locale, attr_name) : globalize.send(:fetch_attribute, locale, attr_name) | ||
end | ||
end | ||
|
||
def define_setter(attr_name, locale) | ||
localized_attr_name = localized_attr_name_for(attr_name, locale) | ||
|
||
define_method :"#{localized_attr_name}=" do |value| | ||
attribute_will_change!(localized_attr_name) if value != send(localized_attr_name) | ||
write_attribute(attr_name, value, :locale => locale) | ||
translation_for(locale)[attr_name] = value | ||
end | ||
if respond_to?(:accessible_attributes) && accessible_attributes.include?(attr_name) | ||
attr_accessible :"#{localized_attr_name}" | ||
end | ||
self.globalize_attribute_names << localized_attr_name.to_sym | ||
end | ||
|
||
def each_attribute_and_locale(options) | ||
options[:attributes].each do |attr_name| | ||
options[:locales].each do |locale| | ||
yield attr_name, locale | ||
end | ||
end | ||
end | ||
|
||
module InstanceMethods | ||
def localized_attr_name_for(attr_name, locale) | ||
self.class.localized_attr_name_for(attr_name, locale) | ||
end | ||
end | ||
end | ||
|
||
ActiveRecord::Base.extend Globalize::Accessors |
36 changes: 0 additions & 36 deletions
36
releaf-core/lib/releaf/rails_ext/validation_error_codes.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +0,0 @@ | ||
module ActiveModel | ||
class ErrorMessage < String | ||
attr_accessor :error_code, :data | ||
|
||
def initialize(message, error_code = nil, data = nil) | ||
super message | ||
@error_code = error_code | ||
@data = data | ||
end | ||
end | ||
|
||
class Errors | ||
def add(attribute, message = nil, options = {}) | ||
# build error code from message symbol | ||
error_code = normalize_error_code(attribute, message, options) | ||
message = normalize_message(attribute, message, options) | ||
if exception = options[:strict] | ||
exception = ActiveModel::StrictValidationFailed if exception == true | ||
raise exception, full_message(attribute, message) | ||
end | ||
|
||
# use customized String subclass with "error_code" attribute | ||
self[attribute] << ErrorMessage.new(message, error_code, options[:data]) | ||
end | ||
|
||
def normalize_error_code(_attribute, message, options) | ||
if !options[:error_code].blank? | ||
options[:error_code] | ||
elsif message.class == Symbol | ||
message | ||
else | ||
:invalid | ||
end | ||
end | ||
end | ||
end | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.