Moved RELATIONABLE_MODELS from controller to model

This commit is contained in:
María Checa
2017-12-14 18:26:52 +01:00
parent 45a0b73e31
commit 88fc740863
3 changed files with 3 additions and 3 deletions

View File

@@ -1,5 +1,4 @@
class RelatedContentsController < ApplicationController
RELATIONABLE_MODELS = %w{proposals debates}
VALID_URL = /#{Setting['url']}\/.*\/.*/
skip_authorization_check
@@ -31,7 +30,7 @@ class RelatedContentsController < ApplicationController
if valid_url?
url = params[:url]
related_klass = url.match(/\/(#{RELATIONABLE_MODELS.join("|")})\//)[0].gsub("/", "")
related_klass = url.match(/\/(#{RelatedContent::RELATIONABLE_MODELS.join("|")})\//)[0].gsub("/", "")
related_id = url.match(/\/[0-9]+/)[0].gsub("/", "")
@related = (related_klass.singularize.camelize.constantize).find_by_id(related_id)

View File

@@ -1,5 +1,6 @@
class RelatedContent < ActiveRecord::Base
RELATED_CONTENTS_REPORT_THRESHOLD = Setting['related_contents_report_threshold'].to_i
RELATIONABLE_MODELS = %w{proposals debates}
belongs_to :parent_relationable, polymorphic: true
belongs_to :child_relationable, polymorphic: true

View File

@@ -2,7 +2,7 @@
<label><%= t("related_content.label") %></label>
<p class="help-text" id="related_content_help_text">
<%= t("related_content.help", org: setting['org_name']) %>
<%= t("related_content.help", models: t('related_content.content_title').values.to_sentence, org: setting['org_name']) %>
</p>
<div class="input-group">