Commit ac2024bb authored by Vanessa Silva's avatar Vanessa Silva
Browse files

Fixing rubocop

parent 61fd682a
Pipeline #41873 passed with stage
in 2 minutes and 13 seconds
class MessagesController < ApplicationController
def index
def index
@users = User.all
@current_matches = current_user.match_users if user_signed_in?
end
end
def show
def show # rubocop:disable Metrics/AbcSize
@sender = User.find(params[:users][:ids])
@receiver = User.find(params[:receiver_id])
@messages = Message.where(sender_id: @sender.id, receiver_id: @receiver.id).or(Message.where(sender_id: @receiver.id, receiver_id: @sender.id))
@chat_id = [@sender.id, @receiver.id].sort.join("")
@chat_id = [@sender.id, @receiver.id].sort.join("")
end
def create
message = Message.create(sender_id: params[:sender_id], receiver_id: params[:receiver_id], text: params[:message])
def create
Message.create(sender_id: params[:sender_id], receiver_id: params[:receiver_id], text: params[:message])
redirect_back(fallback_location: "/users")
end
end
end
......@@ -20,7 +20,7 @@ class User < ApplicationRecord
has_many :matched_users_two, through: :matches_two, source: :user_one
# Messages
has_many :messagee, foreign_key: :receiver_id, class_name: 'Message'
has_many :messagee, foreign_key: :receiver_id, class_name: 'Message'
has_many :senders, through: :messagee
has_many :messaged, foreign_key: :sender_id, class_name: 'Message'
has_many :receivers, through: :messaged
......@@ -29,7 +29,7 @@ class User < ApplicationRecord
:recoverable, :rememberable, :validatable
validates :birthday, presence: true
validates :username, :email, presence: true, uniqueness: true
validates :profile_picture, content_type: ["image/jpeg", "image/png", "image/jpg"]
validates :profile_picture, content_type: ["image/jpeg", "image/png", "image/jpg"]
def age
((Date.today - birthday.to_date) / 365).floor
......
......@@ -70,12 +70,8 @@ Rails.application.configure do
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_cable.url = 'ws://localhost:3000/cable'
end
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