You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Its better to use new_orders_path then /orders/new
When things become more complicated, do you feel the order_controller.rb is a little bit messy? It is doing a lot of stuffs. Good practices are to use PORO you can check it out here. Or you can try to put some code like calculate_discount_price to the model layer
# In controller do this@sections=["Breakfast","Lunch","Dinner","Drinks"]# And in views you can do:
<divclass="btn-group"role="group"aria-label="section">
<% @sections.eachdo |section| %> <%= link_to section, menus_path(section: section), class: "btn btn-secondary #{'active'if@section == section}" %>
<% end %></div>
or even better way:
# Create a partial view name it: sections/_section.html.erb
<%= link_tosection,menus_path(section: section),class: "btn btn-secondary #{'active'ifselected_section == section}"%># In controller do this@sections = ["Breakfast", "Lunch", "Dinner", "Drinks"]# And in views you can do:<div class="btn-group" role="group" aria-label="section">
<%= renderpartial: 'sections/section',collection: @sections,as: :section,locals: {selected_section: @section}
</div>
actually there are a better way then this (which I think the best way for me), but we can talk about it later, its more advance and architecture matter
You have done most part of the homework, really appreciate your work
Goals of this homework:
Great stuffs:
Good use of
raty.js
libraryGood use of
has_many
andbelongs_to
relationship, you look confident to use these methodsBeautiful User Interface
Really good use of
validation
on modelsYou look confident using
order
andwhere
, really awesome stuffsYou have already used
session
fluently, great job manVery nice way to validate email
Very nice way of rendering, you know a lot of stuffs man
Suggestions:
Its better to use
new_orders_path
then/orders/new
When things become more complicated, do you feel the
order_controller.rb
is a little bit messy? It is doing a lot of stuffs. Good practices are to use PORO you can check it out here. Or you can try to put some code likecalculate_discount_price
to the model layerThis code:
can be refactor something like:
or even better way:
actually there are a better way then this (which I think the best way for me), but we can talk about it later, its more advance and architecture matter
This code:
can be refactored into something shorter
or something even shorter
these approaches produce cleaner and more readable code, because someone may have to maintain your code
Overall, you really push effort to do the homework. A lot of nice stuffs have been done. I love your submission most. Please keep it up
The text was updated successfully, but these errors were encountered: