minhchau273 / cheetah-restaurant

Assignment 1 in Ruby course
1 stars 0 forks source link

[Ruby][Assignment 1] - Review my app #1

Open minhchau273 opened 8 years ago

minhchau273 commented 8 years ago

Hi @harley, Could you please review my homework? Sorry I didn't complete all the required feature :disappointed: Thank you!

harley commented 8 years ago

Great stuff!!

Suggestions:

  def image_url_or_default
    if image_url.present?
      image_url
    else
      "#{IMAGE_BASE_URL}#{CGI.escape name}"
    end
  end

Additionally, I know I wrote this code in the walkthrough so that it's readable to new Rubists. As you are more comfortable Ruby, you can write it more idiomatically as

def image_url_or_default
  image_url.presence || "#{IMAGE_BASE_URL}#{CGI.escape name}"
end
# file: menu_controller.rb
def index
  @sections = Section.all
  @section = Section.find_by_id(params[:session]) || Section.first

  @sort = params[:sort] || "alphabetical"
  @menu_items = MenuItem.filter(@section.menu_items, @sort)
end

Note you'd have to define def self.filter yourself in MenuItem model.

You can improve it further by:

Thanks for giving this homework a try. Look forward to your feedback on ways to make it better as well.

chug2k commented 8 years ago

+1. What we really need is a set of guides and/or guides (documents) to help explain certain key concepts useful in this homework.

Amazing job to both of you.