Rubocop style autocorrections

This commit is contained in:
Bertocq
2017-12-16 17:52:50 +01:00
parent cf8cfe363b
commit b02e2729e7
4 changed files with 12 additions and 14 deletions

View File

@@ -22,21 +22,19 @@ class RelatedContentsController < ApplicationController
end
def relationable_object
@relationable = (params[:relationable_klass].singularize.camelize.constantize).find_by_id(params[:relationable_id])
@relationable = params[:relationable_klass].singularize.camelize.constantize.find_by(id: params[:relationable_id])
end
def related_object
begin
if valid_url?
url = params[:url]
related_klass = url.match(/\/(#{RelatedContent::RELATIONABLE_MODELS.join("|")})\//)[0].gsub("/", "")
related_id = url.match(/\/[0-9]+/)[0].gsub("/", "")
related_klass = url.match(/\/(#{RelatedContent::RELATIONABLE_MODELS.join("|")})\//)[0].delete("/")
related_id = url.match(/\/[0-9]+/)[0].delete("/")
@related = (related_klass.singularize.camelize.constantize).find_by_id(related_id)
@related = related_klass.singularize.camelize.constantize.find_by(id: related_id)
end
rescue
rescue
nil
end
end
end

View File

@@ -25,8 +25,8 @@ module Notifiable
def check_availability(resource)
resource.present? &&
resource.try(:hidden_at) == nil &&
resource.try(:retired_at) == nil
resource.try(:hidden_at).nil? &&
resource.try(:retired_at).nil?
end
def linkable_resource

View File

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

View File

@@ -1,6 +1,6 @@
namespace :polls do
desc "Adds created_at and updated_at values to existing polls"
task initialize_timestamps: :environment do
Poll.update_all(created_at: Time.current, updated_at: Time.current)
end
desc "Adds created_at and updated_at values to existing polls"
task initialize_timestamps: :environment do
Poll.update_all(created_at: Time.current, updated_at: Time.current)
end
end