Skip to content

Feed - #22

Open
kotlav wants to merge 84 commits into
masterfrom
feed
Open

Feed#22
kotlav wants to merge 84 commits into
masterfrom
feed

Conversation

@kotlav

@kotlav kotlav commented Jun 19, 2017

Copy link
Copy Markdown
Collaborator

No description provided.

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

Copy link
Copy Markdown

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
Copy Markdown
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])

Copy link
Copy Markdown

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
Copy Markdown
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

Copy link
Copy Markdown

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
Copy Markdown
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])

Copy link
Copy Markdown

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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment thread app/controllers/issues_controller.rb Outdated
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]

Copy link
Copy Markdown

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
Copy Markdown
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'

Comment thread app/controllers/issues_controller.rb Outdated

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)

Copy link
Copy Markdown

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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sure, removed.

Comment thread app/controllers/users_controller.rb Outdated

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

Copy link
Copy Markdown

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
Copy Markdown
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.

Comment thread app/helpers/sessions_helper.rb Outdated
# Returns true if the user is logged in, false otherwise.
def logged_in?
!current_user.nil?
!@current_user.nil?

Copy link
Copy Markdown

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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment thread app/models/social_interest.rb Outdated
has_and_belongs_to_many :users
has_and_belongs_to_many :issues

# def initialize(hash)

Copy link
Copy Markdown

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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed

Comment thread app/models/user.rb Outdated
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"

Copy link
Copy Markdown

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
Copy Markdown
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.

@kotlav kotlav left a comment

Copy link
Copy Markdown
Collaborator Author

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.

3 participants