belongs_to :user
has_many :widgets, :include => 'properties', :dependent => :destroy
- has_many :active_dashboards, :dependent => :destroy
+ has_many :active_dashboards, :dependent => :destroy, :inverse_of => :dashboard
validates_length_of :name, :within => 1..256
validates_length_of :description, :maximum => 1000, :allow_blank => true, :allow_nil => true
validates_presence_of :name, :description, :plugin_name
validates_presence_of :plugin_rule_key, :if => 'name.present?'
- has_many :rules_parameters
- has_many :rule_failures
- has_many :active_rules
+ has_many :rules_parameters, :inverse_of => :rule
+ has_many :rule_failures, :inverse_of => :rule
+ has_many :active_rules, :inverse_of => :rule
belongs_to :parent, :class_name => 'Rule', :foreign_key => 'parent_id'
- has_one :rule_note
+ has_one :rule_note, :inverse_of => :rule
alias_attribute :note, :rule_note
def repository_key
param_type[2, param_type.length-3].split(",")
end
- # We can provide the rule as parameter to avoid reloading this rule_parameter's rule.
- # This hack would be useless if we could use :inverse_of on :rule
- def description(param_rule = rule)
- @l10n_description ||=
- begin
- result = Java::OrgSonarServerUi::JRubyFacade.getInstance().getRuleParamDescription(I18n.locale, param_rule.repository_key, param_rule.plugin_rule_key, name())
- result = read_attribute(:description) unless result
- result
- end
- end
-
def description=(value)
write_attribute(:description, value)
end
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
#
class Widget < ActiveRecord::Base
- has_many :properties, :dependent => :delete_all, :class_name => 'WidgetProperty'
+ has_many :properties, :dependent => :delete_all, :class_name => 'WidgetProperty', :inverse_of => :widget
belongs_to :dashboards
belongs_to :resource, :class_name => 'Project'
<% end %>
<% end %>
- <div class="form-val-note"><%= h(parameter.description(rule) || "") -%> <%= ('(' + readable_type(parameter.param_type) + ')') if !readable_type(parameter.param_type).empty? -%></div>
+ <div class="form-val-note"><%= h(parameter.rule.description || "") -%> <%= ('(' + readable_type(parameter.param_type) + ')') if !readable_type(parameter.param_type).empty? -%></div>
</form>
</td>