Skip to content

Conversation

@kotlav
Copy link
Collaborator

@kotlav kotlav commented Jun 19, 2017

No description provided.

private
def current_user
@current_user ||= User.find_by_id(session[:user_id])
if (user_id = session[:user_id])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kotlav I thinks its ==

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its assignment, not comparison

@current_user ||= User.find_by_id(session[:user_id])
if (user_id = session[:user_id])
@current_user ||= User.find_by(id: user_id)
elsif (user_id = cookies.signed[:user_id])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kotlav I thinks it's ==

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its assignment, not comparison

extend ActiveSupport::Concern

def update_support_issue
byebug

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kotlav Remove byebug

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.


def update_support_issue
byebug
issue = Issue.all.find(params[:issue_id])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kotlav Issue.find()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

before_action :logged_in_user, only: [:create, :destroy]
before_action :correct_user, only: :destroy

before_action :verify_user_has_logged_in, only: [:new, :create, :destroy]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kotlav This filter should be there for every action. Move this filter to base controller.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is like that, 'verify_user_has_logged_in' method is defined in the base class 'ApplicationController'


def issue_params
params.require(:issue).permit(:content, :imageurl, :user_id, :title)
params.require(:issue).permit(:content, :imageurl, :user_id, :title, :impact, :cost, :socialinterest_ids)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't allow user_id and you shouldn't populate user_id field in issue creation form.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, removed.


include UsersHelper
before_action :redirect_if_logged_in, only: [:new, :create]
before_action :verify_user_has_logged_in, only: [:show]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to base controller.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'verify_user_has_logged_in' is defined in base controller only.

# Returns true if the user is logged in, false otherwise.
def logged_in?
!current_user.nil?
!@current_user.nil?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kotlav @current_user.present?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

has_and_belongs_to_many :users
has_and_belongs_to_many :issues

# def initialize(hash)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kotlav If you don't need remove.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

class User < ApplicationRecord
has_many :issues, dependent: :destroy
has_many :issues, dependent: :destroy # created issues
has_and_belongs_to_many :social_interests, class_name: "SocialInterest"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kotlav I think there is no need of giving class_name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought of giving another name for member var name, that's why put a class there. For my reference, I keep it for now.

Copy link
Collaborator Author

@kotlav kotlav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done the changes according to the feedback. Please review it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants