-
Notifications
You must be signed in to change notification settings - Fork 1
Feed #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| private | ||
| def current_user | ||
| @current_user ||= User.find_by_id(session[:user_id]) | ||
| if (user_id = session[:user_id]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kotlav I thinks its ==
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
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 ==
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kotlav Remove byebug
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kotlav Issue.find()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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'
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, removed.
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] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kotlav @current_user.present?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
app/models/social_interest.rb
Outdated
| has_and_belongs_to_many :users | ||
| has_and_belongs_to_many :issues | ||
|
|
||
| # def initialize(hash) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this 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.
No description provided.