Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="field">
- <%= f.label :delivery_areas %>
- <% Area.all.each do |area| %>
- <%= check_box_tag("area", "name") %>
- <%= area.name %>
- <% end %>
- </div>
- def index
- @restaurants = Restaurant.all.order("created_at DESC")
- if params[:area].blank?
- @restaurants = Restaurant.all.order("created_at DESC")
- else
- @area_id = Area.find_by(name: params[:area]).id
- @restaurants = Restaurant.where(:area_id => @area_id).order("created_at DESC")
- end
- if @reviews.blank?
- @avg_review = 0
- else
- @avg_review = @reviews.average(:rating).round(2)
- end
- end
- <ul>
- <li class="dropdown area-dropdown">
- <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" style="width: 440px;">
- area
- <span class="caret"></span>
- </button>
- <ul class="dropdown-menu scrollable-menu" aria-labelledby="dropdownMenu1" style="width: 440px;">
- <% @areas.each do |area| %>
- <li>
- <%= link_to area.name, restaurants_path(area: area.name), class: "link" %>
- </li>
- <% end %>
- </ul>
- </li>
- </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement