Skip to content

Commit 53c47be

Browse files
author
Mikey
committed
Added jquery-rails, and added Maps controller.
1 parent cd9f550 commit 53c47be

20 files changed

+21377
-9295
lines changed

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ gem 'cancan'
1212
#gem 'coffee-rails'
1313
#gem 'sass-rails'
1414
gem 'rspec-rails'
15+
gem 'jquery-rails'
1516

1617
# Use unicorn as the web server
1718
# gem 'unicorn'

Gemfile.lock

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ GEM
4040
erubis (2.6.6)
4141
abstract (>= 1.0.0)
4242
i18n (0.5.0)
43+
jquery-rails (1.0.12)
44+
railties (~> 3.0)
45+
thor (~> 0.14)
4346
mail (2.2.19)
4447
activesupport (>= 2.3.6)
4548
i18n (>= 0.4.0)
@@ -99,6 +102,7 @@ PLATFORMS
99102
DEPENDENCIES
100103
cancan
101104
devise
105+
jquery-rails
102106
mysql2 (~> 0.2.7)
103107
nokogiri
104108
rails (= 3.0.7)
+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
class ApplicationController < ActionController::Base
22
protect_from_forgery
33

4-
before_filter :authenticate_user!
4+
#before_filter :authenticate_user!
5+
6+
57
end

app/controllers/map_controller.rb

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class MapController < ApplicationController
2+
3+
# Load a standard Google map. On page load, this views the UK, showing all gigs for the
4+
# last, and next, six months.
5+
def show
6+
@comedians = Comedian.all
7+
@tours = Tour.all
8+
9+
@months_ago = 6
10+
@months_since = 6
11+
@gigs = Gig.where(:date => Time.now.months_ago(@months_ago)..Time.now.months_since(@months_since))
12+
end
13+
14+
15+
end

app/helpers/map_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module MapHelper
2+
end

app/views/layouts/application.html.erb

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
<%= stylesheet_link_tag :all %>
66
<%= javascript_include_tag :defaults %>
77
<%= csrf_meta_tag %>
8+
<script type="text/javascript">
9+
<%= yield :map %>
10+
</script>
811
</head>
912
<body>
1013

app/views/map/show.html.erb

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<% content_for :map do %>
2+
$(function() {
3+
$("#date_range").slider({
4+
step: 1,
5+
min: <%= @months_ago %>,
6+
max: <%= @months_since %>
7+
});
8+
});
9+
<% end %>
10+
11+
<div id="map_canvas"></div>
12+
<form id="select_gigs">
13+
<h3>Comedian</h3>
14+
<select id="comedian" name="comedian">
15+
<% @comedians.each do |c| %>
16+
<option value="<%= c.id %>"><%= c.name %></option>
17+
<% end %>
18+
</select>
19+
<h3>Tour</h3>
20+
<select id="tour" name="tour">
21+
<% @tours.each do |t| %>
22+
<option value="<%= t.id %>"><%= t.name %></option>
23+
<% end %>
24+
</select>
25+
<h3>Date range</h3>
26+
<div id="date_range"></div>
27+
<input type="submit" id="update_gigs" value="Update" />
28+
</form>

config/routes.rb

+2-56
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,14 @@
11
Comedy::Application.routes.draw do
2-
resources :videos
32

3+
resources :videos
44
resources :gigs
5-
65
resources :tours
7-
86
resources :comedians
97

108
devise_for :users
119

12-
# The priority is based upon order of creation:
13-
# first created -> highest priority.
14-
15-
# Sample of regular route:
16-
# match 'products/:id' => 'catalog#view'
17-
# Keep in mind you can assign values other than :controller and :action
18-
19-
# Sample of named route:
20-
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
21-
# This route can be invoked with purchase_url(:id => product.id)
22-
23-
# Sample resource route (maps HTTP verbs to controller actions automatically):
24-
# resources :products
25-
26-
# Sample resource route with options:
27-
# resources :products do
28-
# member do
29-
# get 'short'
30-
# post 'toggle'
31-
# end
32-
#
33-
# collection do
34-
# get 'sold'
35-
# end
36-
# end
37-
38-
# Sample resource route with sub-resources:
39-
# resources :products do
40-
# resources :comments, :sales
41-
# resource :seller
42-
# end
43-
44-
# Sample resource route with more complex sub-resources
45-
# resources :products do
46-
# resources :comments
47-
# resources :sales do
48-
# get 'recent', :on => :collection
49-
# end
50-
# end
51-
52-
# Sample resource route within a namespace:
53-
# namespace :admin do
54-
# # Directs /admin/products/* to Admin::ProductsController
55-
# # (app/controllers/admin/products_controller.rb)
56-
# resources :products
57-
# end
58-
59-
# You can have the root of your site routed with "root"
60-
# just remember to delete public/index.html.
61-
root :to => "comedians#index"
10+
root :to => "map#show"
6211

6312
# See how all your routes lay out with "rake routes"
6413

65-
# This is a legacy wild controller route that's not recommended for RESTful applications.
66-
# Note: This route will make all actions in every controller accessible via GET requests.
67-
# match ':controller(/:action(/:id(.:format)))'
6814
end

0 commit comments

Comments
 (0)