Commit 28058328 authored by simon's avatar simon
Browse files

Add manual rubocop fixes

parent 32ecc3ce
......@@ -31,6 +31,7 @@ Metrics/AbcSize:
Metrics/BlockLength:
Exclude:
- config/**/*
- Guardfile #guard extension hash is too big
Metrics/MethodLength:
Max: 20
......@@ -49,3 +50,8 @@ Style/HashTransformKeys:
Style/HashTransformValues:
Enabled: true
Rails/LexicallyScopedActionFilter:
Exclude:
- app/controllers/users/registrations_controller.rb #class inherits from parent devise class (super)
......@@ -20,7 +20,6 @@
guard 'livereload' do
extensions = {
css: :css,
scss: :css,
scss: :scss,
sass: :css,
js: :js,
......
......@@ -2,7 +2,7 @@
# This controller handles comments
class CommentsController < ApplicationController
before_action :set_comment, only: %w[show edit update destroy]
before_action :set_comment, only: %w[update destroy]
# GET /comments/new
def new
......
......@@ -2,8 +2,8 @@
# this controller handles conversations
class ConversationsController < ApplicationController
before_action :set_conversation, only: %w[show create new]
before_action :check_engaged, only: %w[show create new]
before_action :set_conversation, only: %w[show]
before_action :check_engaged, only: %w[show]
def index
@conversations = Conversation.engaged(current_user).order('updated_at DESC')
......
# frozen_string_literal: true
# inherits from Devise::RegistrationsController and allows registration with username param
module Users
# inherits from Devise::RegistrationsController and allows registration with username param
class RegistrationsController < Devise::RegistrationsController
before_action :configure_sign_up_params, only: [:create]
before_action :configure_account_update_params, only: [:update]
......
# frozen_string_literal: true
# handles various user actions but no devise actions (e.g registration, sign_in,...)
class UsersController < ApplicationController
before_action :set_user, only: %w[show update]
......
# frozen_string_literal: true
# various helper methods used throughout the codebase
module ApplicationHelper
def utc_to_readable(time)
time.strftime('%d %b. %H:%M')
......
# frozen_string_literal: true
# various helper methods for comments
module CommentsHelper
end
# frozen_string_literal: true
# various helper methods for conversations
module ConversationHelper
end
# frozen_string_literal: true
# various helper methods for conversations messages
module ConversationMessagesHelper
end
# frozen_string_literal: true
# various helper methods for users
module UsersHelper
def own_profile?(user)
true if current_user == user
......
# frozen_string_literal: true
# application record model
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
# frozen_string_literal: true
# Conversation model
class Conversation < ApplicationRecord
validates :author, uniqueness: { scope: :receiver }
belongs_to :author, class_name: 'User'
belongs_to :receiver, class_name: 'User'
has_many :conversation_messages, -> { order(created_at: :asc) }, dependent: :destroy
has_many :conversation_messages, -> { order(created_at: :asc) }, dependent: :destroy, inverse_of: :conversation
# return all conversations that the user is engaged in
scope :engaged, lambda { |user|
......
......@@ -14,7 +14,7 @@ class Post < ApplicationRecord
has_many_attached :content_image, dependent: :destroy
has_many_attached :content_file, dependent: :destroy
has_many :comments, -> { order(created_at: :asc) }, dependent: :destroy
has_many :comments, -> { order(created_at: :asc) }, dependent: :destroy, inverse_of: :post
# can be voted on
acts_as_votable
......
# frozen_string_literal: true
# User model
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
......@@ -8,8 +9,10 @@ class User < ApplicationRecord
has_many :posts, dependent: :destroy
has_many :comments, dependent: :destroy
has_many :authored_conversations, class_name: 'Conversation', foreign_key: 'author_id'
has_many :received_conversations, class_name: 'Conversation', foreign_key: 'received_id'
has_many :authored_conversations, class_name: 'Conversation', foreign_key: 'author_id', inverse_of: :user,
dependent: :destroy
has_many :received_conversations, class_name: 'Conversation', foreign_key: 'received_id', inverse_of: :user,
dependent: :destroy
has_many :conversation_messages, dependent: :destroy
scope :all_except, ->(user) { where.not(id: user) }
......@@ -26,7 +29,7 @@ class User < ApplicationRecord
acts_as_ordered_taggable_on :user_tags
def set_default_avatar
avatar.attach(io: File.open(Rails.root.join('app', 'assets', 'images', 'profile_image.png')),
avatar.attach(io: File.open(Rails.root.join('app/assets/images/profile_image.png')),
filename: 'default-avatar.png', content_type: 'image/png')
end
end
......@@ -10,6 +10,7 @@ require 'active_storage/engine'
Bundler.require(*Rails.groups)
module CodeBunker
# Main Rails config file
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.0
......
......@@ -17,7 +17,7 @@ Rails.application.configure do
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join('tmp', 'caching-dev.txt').exist?
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
......
......@@ -15,4 +15,4 @@ Rails.application.config.assets.paths << Rails.root.join('node_modules')
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
Rails.application.config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
Rails.application.config.assets.paths << Rails.root.join('app/assets/fonts')
......@@ -14,7 +14,7 @@ Devise.setup do |config|
# confirmation, reset password and unlock tokens in the database.
# Devise will use the `secret_key_base` as its `secret_key`
# by default. You can change it below and use your own secret key.
# config.secret_key = '55012994a8789cb13b8a1948a39369b12b497fd471e03d79bde4c8945ba1759fd2a7176d6285f1da6c922ea44fd4b7092ac5a313112a7af3c0f53d4b39ef20f1'
# config.secret_key = ''
# ==> Controller configuration
# Configure the parent class to the devise controllers.
......@@ -126,7 +126,7 @@ Devise.setup do |config|
config.stretches = Rails.env.test? ? 1 : 12
# Set up a pepper to generate the hashed password.
# config.pepper = '3f43f6b9982d86be68e9e90361944a536ee3f063eb7a2bd0dba13bc1fd37ae596567a25929c93a3beee67ce296f6c04f0ac41d9c74df7671de04778fb10bc0fa'
# config.pepper = ''
# Send a notification to the original email when the user's email is changed.
# config.send_email_changed_notification = false
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment