-
Notifications
You must be signed in to change notification settings - Fork 1
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
Create restaurants table and develop manager's manage menu page #24
Conversation
ChrisKheng
commented
Feb 27, 2020
- Create restaurants table and link it to managers table.
- Refactor manager's manage pages (manage menu, promo & restaurant info).
- Develop basic manage menu page.
@@ -82,5 +82,6 @@ | |||
add_foreign_key "admins", "users" | |||
add_foreign_key "customers", "users" | |||
add_foreign_key "managers", "users" | |||
add_foreign_key "restaurants", "managers", on_delete: :cascade |
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.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
@@ -46,7 +46,7 @@ | |||
t.decimal "minOrderCost", null: false | |||
t.datetime "created_at", precision: 6, null: false | |||
t.datetime "updated_at", precision: 6, null: false | |||
t.index ["manager_id"], name: "index_restaurants_on_manager_id" | |||
t.index ["manager_id"], name: "index_restaurants_on_manager_id", unique: true |
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.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Metrics/LineLength: Line is too long. [81/80]
@@ -10,7 +10,7 @@ | |||
# | |||
# It's strongly recommended that you check this file into your version control system. | |||
|
|||
ActiveRecord::Schema.define(version: 2020_02_25_011425) do | |||
ActiveRecord::Schema.define(version: 2020_02_26_014752) do |
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.
Metrics/BlockLength: Block has too many lines. [64/25]
Style/NumericLiterals: Use underscores(_) as decimal mark and separate every 3 digits with them.
@@ -0,0 +1,7 @@ | |||
class AddIndexToRestaurants < ActiveRecord::Migration[6.0] |
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.
Style/Documentation: Missing top-level class documentation comment.
Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
|
||
# Returns a customised user which only consists of attributes that are chosen to be exposed. | ||
def get_user_hash(user) | ||
userHash = {id: user.id, username: user.username, email: user.email, roles: user.roles} |
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.
Lint/UselessAssignment: Useless assignment to variable - userHash. Did you mean user?
Naming/VariableName: Use snake_case for variable names.
Layout/SpaceInsideHashLiteralBraces: Space inside { missing.
Metrics/LineLength: Line is too long. [93/80]
Layout/SpaceInsideHashLiteralBraces: Space inside } missing.
user = current_user | ||
manager = Manager.find_by_sql("SELECT * FROM managers WHERE user_id = #{user.id} LIMIT 1")[0] | ||
restaurant = Restaurant.find_by_sql("SELECT * FROM restaurants WHERE manager_id = #{manager.id} LIMIT 1")[0] | ||
|
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.
Layout/TrailingWhitespace: Trailing whitespace detected.
app/helpers/managers_helper.rb
Outdated
# Get the current user, manager, and restaurant | ||
user = current_user | ||
manager = Manager.find_by_sql("SELECT * FROM managers WHERE user_id = #{user.id} LIMIT 1")[0] | ||
restaurant = Restaurant.find_by_sql("SELECT * FROM restaurants WHERE manager_id = #{manager.id} LIMIT 1")[0] |
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.
Metrics/LineLength: Line is too long. [112/80]
app/helpers/managers_helper.rb
Outdated
def get_current_manager() | ||
# Get the current user, manager, and restaurant | ||
user = current_user | ||
manager = Manager.find_by_sql("SELECT * FROM managers WHERE user_id = #{user.id} LIMIT 1")[0] |
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.
Metrics/LineLength: Line is too long. [97/80]
app/helpers/managers_helper.rb
Outdated
@@ -0,0 +1,15 @@ | |||
module ManagersHelper | |||
def get_current_manager() |
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.
Naming/AccessorMethodName: Do not prefix reader method names with get_.
Style/DefWithParentheses: Omit the parentheses in defs when the method doesn't accept any arguments.
@@ -0,0 +1,15 @@ | |||
module ManagersHelper |
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.
Style/Documentation: Missing top-level module documentation comment.
Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
else | ||
return false | ||
end | ||
if rolelist.include?(role) |
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.
Layout/IndentationConsistency: Inconsistent indentation detected.
Style/GuardClause: Use a guard clause instead of wrapping the code inside a conditional expression.
@@ -4,13 +4,18 @@ def user_has_role?(role) | |||
return false | |||
end | |||
|
|||
rolelist = current_user.roles.split(',') | |||
rolelist = current_user.roles.split(',') |
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.
Layout/IndentationConsistency: Inconsistent indentation detected.