Revision 92845892
Added by Dominic Cleal over 6 years ago
app/models/concerns/nested_ancestry_common.rb | ||
---|---|---|
max_length_for_name = 255 - length_of_matcher
|
||
current_title_length = max_length_for_name - name.length
|
||
|
||
errors.add(:name, n_("is too long (maximum is 1 character)", "is too long (maximum is %s characters)", max_length_for_name) % max_length_for_name) if (errors.get(:name).blank? && current_title_length < 0)
|
||
errors.add(:name, n_("is too long (maximum is 1 character)", "is too long (maximum is %s characters)", max_length_for_name) % max_length_for_name) if (errors[:name].empty? && current_title_length < 0)
|
||
end
|
||
end
|
||
end
|
app/models/concerns/parameter_validators.rb | ||
---|---|---|
self.send(parameters_symbol).each do |param|
|
||
next unless param.new_record? # normal validation would catch this
|
||
if names.include?(param.name)
|
||
param.errors[:name] = _('has already been taken')
|
||
param.errors.add(:name, _('has already been taken'))
|
||
errors = true
|
||
else
|
||
names << param.name
|
||
end
|
||
end
|
||
self.errors[parameters_symbol] = _('Please ensure the following parameters name are unique') if errors
|
||
self.errors.add(parameters_symbol, _('Please ensure the following parameters name are unique')) if errors
|
||
end
|
||
|
||
def parameters_symbol
|
app/views/hosts/_dhcp_lease_errors.html.erb | ||
---|---|---|
<p><%= _('Please correct the error(s) below and submit your changes again.') %></p>
|
||
|
||
<div class="alert alert-warning alert-block base">
|
||
<% @host.errors.get(:dhcp_lease_error).each do |e| %>
|
||
<% @host.errors[:dhcp_lease_error].each do |e| %>
|
||
<li><%= e %></li>
|
||
<% end %>
|
||
</div>
|
config/as_deprecation_whitelist.yaml | ||
---|---|---|
---
|
||
# Pending fixes, compatible with Rails 4.2 and 5.0
|
||
- message: ActiveModel::Errors#[]= is deprecated and will be removed in Rails 5.1.
|
||
Use model.errors.add(:name, "has already been taken") instead.
|
||
callstack: app/models/concerns/parameter_validators.rb:15:in `block in validate_parameters_names'
|
||
- message: ActiveModel::Errors#[]= is deprecated and will be removed in Rails 5.1.
|
||
Use model.errors.add(:os_parameters, "Please ensure the following parameters name
|
||
are unique") instead.
|
||
callstack: app/models/concerns/parameter_validators.rb:21:in `validate_parameters_names'
|
||
- message: ActiveModel::Errors#get is deprecated and will be removed in Rails 5.1.
|
||
To achieve the same use model.errors[:name].
|
||
callstack: app/models/concerns/nested_ancestry_common.rb
|
||
- message: 'Method each_value is deprecated and will be removed in Rails 5.1, as `ActionController::Parameters`
|
||
no longer inherits from hash. Using this deprecated behavior exposes potential
|
||
security problems. If you continue to use this method you may be creating a security
|
Also available in: Unified diff
Fixes #20949 - Replace deprecated AM::Errors usage