Skip to content

Commit

Permalink
Final tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
raghubetina committed Nov 28, 2016
1 parent d9c0f61 commit e18ab48
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 16 deletions.
4 changes: 2 additions & 2 deletions app/controllers/venues_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class VenuesController < ApplicationController
def index
@q = Venue.ransack(params[:q])
@q = current_user.bookmarked_venues.ransack(params[:q])
@venues = @q.result(:distinct => true).includes(:bookmarks, :neighborhood, :fans, :specialties).page(params[:page]).per(100)
@location_hash = Gmaps4rails.build_markers(@venues.where.not(:address_latitude => nil)) do |venue, marker|
marker.lat venue.address_latitude
Expand Down Expand Up @@ -38,7 +38,7 @@ def create

case referer
when "/venues/new", "/create_venue"
redirect_to("/venues")
redirect_to("/dishes")
else
redirect_back(:fallback_location => "/", :notice => "Venue created successfully.")
end
Expand Down
3 changes: 1 addition & 2 deletions app/models/dish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class Dish < ApplicationRecord

# Validations

validates :name, :uniqueness => true
validates :name, :uniqueness => { :case_sensitive => false }

validates :name, :presence => true

end
4 changes: 2 additions & 2 deletions app/models/venue.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Venue < ApplicationRecord
before_save :geocode_address
before_validation :geocode_address

def geocode_address
if self.address.present?
Expand Down Expand Up @@ -38,7 +38,7 @@ def geocode_address

# Validations

validates :name, :uniqueness => { :scope => [:neighborhood_id], :message => "already exists" }
validates :name, :uniqueness => { :scope => [:address_formatted_address], :message => "already exists", :case_sensitive => false }

validates :name, :presence => true

Expand Down
2 changes: 1 addition & 1 deletion app/views/bookmarks/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
Venue
</label>

<%= select_tag(:venue_id, options_from_collection_for_select(Venue.all, :id, :name, @bookmark.venue_id), :class => "form-control") %>
<%= select_tag(:venue_id, options_from_collection_for_select(Venue.order(:name), :id, :name, @bookmark.venue_id), :class => "form-control") %>
</div>


Expand Down
2 changes: 1 addition & 1 deletion app/views/bookmarks/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
Venue
</label>

<%= select_tag(:venue_id, options_from_collection_for_select(Venue.all, :id, :name, @bookmark.venue_id), :class => "form-control") %>
<%= select_tag(:venue_id, options_from_collection_for_select(Venue.order(:name), :id, :name, @bookmark.venue_id), :class => "form-control") %>
</div>

<!-- Label and input for user_id -->
Expand Down
8 changes: 7 additions & 1 deletion app/views/dishes/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
Venue
</label>

<%= select_tag(:venue_id, options_from_collection_for_select(Venue.all, :id, :name), :class => "form-control input-sm", :prompt => "Choose a venue...") %>
<%= select_tag(:venue_id, options_from_collection_for_select(Venue.order(:name), :id, :name), :class => "form-control input-sm", :prompt => "Choose a venue...") %>
</div>

<button class="btn btn-primary btn-sm">
Expand Down Expand Up @@ -104,4 +104,10 @@
</div>
</div>
</div>

<div class="col-md-3">
<a href="/venues/new" class="btn btn-block btn-success">
Add a new venue
</a>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/dishes/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Venue
</label>

<%= select_tag(:venue_id, options_from_collection_for_select(Venue.all, :id, :name), :class => "form-control", :prompt => "Choose a venue...") %>
<%= select_tag(:venue_id, options_from_collection_for_select(Venue.order(:name), :id, :name), :class => "form-control", :prompt => "Choose a venue...") %>
</div>

<button class="btn btn-primary btn">
Expand Down
13 changes: 12 additions & 1 deletion app/views/venues/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@

<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
Places you've bookmarked
</h4>
</div>

<div class="panel-body">
<div id="location_map" style="height: 360px;"></div>
</div>
Expand All @@ -58,12 +64,17 @@
<% end %>
</ul>


<div class="panel-footer text-center">
<%= paginate @venues, theme: 'twitter-bootstrap-4' %>
</div>
</div>
</div>

<div class="col-md-3">
<a href="/venues/new" class="btn btn-block btn-success">
Add a new venue
</a>
</div>
</div>

<script src="//maps.google.com/maps/api/js?v=3.24&key=AIzaSyCOTPWiuvyyo6sKoIBzKA4-1ol-vTOIOlM"></script>
Expand Down
9 changes: 4 additions & 5 deletions app/views/venues/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
<h4 class="panel-title">
<%= @venue.name %>

<% if @venue.neighborhood.present? %>
<small class="text-muted">
<%= @venue.neighborhood.name %>,
<%= @venue.neighborhood.city %>,
<%= @venue.neighborhood.state %>
<% if @venue.neighborhood.present? %>
<%= @venue.neighborhood.name %>,
<%= @venue.address_formatted_address %>
<% end %>
</small>
<% end %>
</h4>
</div>

Expand Down

0 comments on commit e18ab48

Please sign in to comment.