diff --git a/app/controllers/dishes_controller.rb b/app/controllers/dishes_controller.rb index 84facab..5794008 100644 --- a/app/controllers/dishes_controller.rb +++ b/app/controllers/dishes_controller.rb @@ -2,10 +2,10 @@ class DishesController < ApplicationController def index @q = Dish.ransack(params[:q]) @dishes = @q.result(:distinct => true).includes(:cuisine, :bookmarks, :fans, :specialists).page(params[:page]).per(10) - - render("dishes/index.html.erb") + @bookmark = Bookmark.new end + def show @bookmark = Bookmark.new @dish = Dish.find(params[:id]) diff --git a/app/controllers/venues_controller.rb b/app/controllers/venues_controller.rb index c368d81..6071810 100644 --- a/app/controllers/venues_controller.rb +++ b/app/controllers/venues_controller.rb @@ -1,6 +1,7 @@ class VenuesController < ApplicationController def index - @q = Venue.ransack(params[:q]) + @user_venue=current_user.bookmarked_venues + @q = @user_venue.ransack(params[:q]) @venues = @q.result(:distinct => true).includes(:bookmarks, :neighborhood, :fans, :specialties).page(params[:page]).per(10) @location_hash = Gmaps4rails.build_markers(@venues.where.not(:address_latitude => nil)) do |venue, marker| marker.lat venue.address_latitude diff --git a/app/models/dish.rb b/app/models/dish.rb index c435ea1..04cc431 100644 --- a/app/models/dish.rb +++ b/app/models/dish.rb @@ -8,6 +8,7 @@ class Dish < ApplicationRecord :counter_cache => true # Indirect associations + has_many :specialists, :through => :bookmarks, @@ -17,6 +18,7 @@ class Dish < ApplicationRecord :through => :bookmarks, :source => :user + # Validations validates :name, :uniqueness => { :case_sensitive => false } diff --git a/app/views/dishes/index.html.erb b/app/views/dishes/index.html.erb index bc51992..955925e 100644 --- a/app/views/dishes/index.html.erb +++ b/app/views/dishes/index.html.erb @@ -3,7 +3,8 @@ Dishes New Dish -
+
+
<%= search_form_for @q, :class => "collapse", :id => "dishes_filters" do |f| %>

Narrow results:

@@ -53,10 +54,16 @@ }); -
- <%= f.label :cuisine_name_cont, "Cuisine name contains" %> - <%= f.text_field :cuisine_name_cont, :class => "form-control", :placeholder => "Cuisine name contains" %> -
+ +
+ <%= "Cuisines" %> + <% Cuisine.all.each do |cuisine| %> + + <% end %> +
<%= f.label :bookmarks_notes_cont, "Bookmark notes contains" %> @@ -87,29 +94,71 @@
- - - + + + - - <% @dishes.each do |dish| %> - + <% @dishes.each do |dish| %> + + + <% end %>
NameCuisineActionsThe very best...is at...
<%= dish.name %> - <% if dish.cuisine.present? %> - - <%= dish.cuisine.name %> + <% if dish.name.present? %> + + <%= dish.name %> <% end %> - Show - Edit - Delete + <% if dish.specialists.present? %> + <% dish.specialists.each do |venue| %> + + <%= venue.name %> + <% end %> + + <% else %> + +
+ + + + + + + + + + +
+ + +
+ <%= select_tag(:venue_id, options_from_collection_for_select(Venue.all.sort_by {|venue| venue.name}, :id, :name, @bookmark.venue_id), prompt:"Choose a venue...", :class => "form-control input-sm") %> +
+ + + + <% end %> +
+ <% if dish.cuisine.present? %> + + <%= dish.cuisine.name %> + <% end %>
- <%= paginate @dishes, theme: 'twitter-bootstrap-4' %> + + +
+ Add a new venue +
+ +
-
+
\ No newline at end of file diff --git a/app/views/dishes/show.html.erb b/app/views/dishes/show.html.erb index 36415db..9773a6a 100644 --- a/app/views/dishes/show.html.erb +++ b/app/views/dishes/show.html.erb @@ -142,7 +142,7 @@ <% @dish.specialists.each do |venue| %>
  • - <%= venue.name %> +

    <%= venue.name %>

    diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 881e961..44a67e7 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -41,13 +41,11 @@
    - <%= f.label :specialties_name_cont, "Dish name contains" %> + <%= f.label :specialties_name_cont, "Bookmarked dish name contains" %> <%= f.text_field :specialties_name_cont, :class => "form-control", :placeholder => "Dish name contains" %>
    diff --git a/config/routes.rb b/config/routes.rb index 6f92ce5..f2ef964 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,6 @@ Rails.application.routes.draw do - root :to => "venues#index" + # Routes for Homepage link to /dishes page: + root "dishes#index" # Routes for the Bookmark resource: # CREATE diff --git a/grades.yml b/grades.yml index 2f40b8d..3b67b4f 100644 --- a/grades.yml +++ b/grades.yml @@ -1,4 +1,4 @@ --- submission_url: https://grades.firstdraft.com project_token: '' -personal_access_token: +personal_access_token: YMhoFUZydkV3ShNpanUydTYz diff --git a/whitelist.yml b/whitelist.yml index ab11e34..b07ef73 100644 --- a/whitelist.yml +++ b/whitelist.yml @@ -2,3 +2,8 @@ - 127.0.0.1 - 10.240.0.0/16 - "::1" +- 192.157.77.90 +- 128.135.98.68 +- 141.117.117.96 +- 104.234.44.158 +- 208.72.125.2