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 -
Narrow results:
@@ -53,10 +54,16 @@ }); -| Name | -Cuisine | -Actions | +The very best... | +is at... | +|
|---|---|---|---|---|---|
| <%= dish.name %> | + <% @dishes.each do |dish| %>- <% 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 %> + + | + ++ <% if dish.cuisine.present? %> + + <%= dish.cuisine.name %> + <% end %> |
<%= venue.name %>