forked from picandocodigo/RuBeer
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request picandocodigo#3 from jmg/master
Mapas
- Loading branch information
Showing
45 changed files
with
1,593 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the places controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
body { | ||
background-color: #fff; | ||
color: #333; | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; } | ||
|
||
p, ol, ul, td { | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; } | ||
|
||
pre { | ||
background-color: #eee; | ||
padding: 10px; | ||
font-size: 11px; } | ||
|
||
a { | ||
color: #000; | ||
&:visited { | ||
color: #666; } | ||
&:hover { | ||
color: #fff; | ||
background-color: #000; } } | ||
|
||
div { | ||
&.field, &.actions { | ||
margin-bottom: 10px; } } | ||
|
||
#notice { | ||
color: green; } | ||
|
||
.field_with_errors { | ||
padding: 2px; | ||
background-color: red; | ||
display: table; } | ||
|
||
#error_explanation { | ||
width: 450px; | ||
border: 2px solid red; | ||
padding: 7px; | ||
padding-bottom: 0; | ||
margin-bottom: 20px; | ||
background-color: #f0f0f0; | ||
h2 { | ||
text-align: left; | ||
font-weight: bold; | ||
padding: 5px 5px 5px 15px; | ||
font-size: 12px; | ||
margin: -7px; | ||
margin-bottom: 0px; | ||
background-color: #c00; | ||
color: #fff; } | ||
ul li { | ||
font-size: 12px; | ||
list-style: square; } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class MapsController < ApplicationController | ||
|
||
def index | ||
|
||
@places = Place.all | ||
|
||
respond_to do |format| | ||
format.html | ||
format.json { render json: @places } | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
class PlacesController < ApplicationController | ||
# GET /places | ||
# GET /places.json | ||
def index | ||
@places = Place.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @places } | ||
end | ||
end | ||
|
||
# GET /places/1 | ||
# GET /places/1.json | ||
def show | ||
@place = Place.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @place } | ||
end | ||
end | ||
|
||
# GET /places/new | ||
# GET /places/new.json | ||
def new | ||
@place = Place.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @place } | ||
end | ||
end | ||
|
||
# GET /places/1/edit | ||
def edit | ||
@place = Place.find(params[:id]) | ||
end | ||
|
||
# POST /places | ||
# POST /places.json | ||
def create | ||
@place = Place.new(params[:place]) | ||
@place.save | ||
|
||
redirect_to :controller => "maps", :action => "index" | ||
end | ||
|
||
# PUT /places/1 | ||
# PUT /places/1.json | ||
def update | ||
@place = Place.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @place.update_attributes(params[:place]) | ||
format.html { redirect_to @place, notice: 'Place was successfully updated.' } | ||
format.json { head :ok } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @place.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /places/1 | ||
# DELETE /places/1.json | ||
def destroy | ||
@place = Place.find(params[:id]) | ||
@place.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to places_url } | ||
format.json { head :ok } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module PlacesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Place < ActiveRecord::Base | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<% content_for :heads do %> | ||
<script type="text/javascript" src="/js/jquery-ui-1.8.16.custom.min.js"></script> | ||
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> | ||
<script type="text/javascript" src="/js/maps.js"></script> | ||
|
||
<link href="/css/maps.css" media="screen" rel="stylesheet" type="text/css"> | ||
<% end %> | ||
|
||
|
||
<body> | ||
|
||
<form action="/places/" method="POST"> | ||
<label>Place Address: </label><input id="address" name="place[address]" type="text"/> | ||
<label>Beer Rate:</label><input id="rate" name="place[rate]" type="text"/> | ||
<input id="latitude" name="place[latitude]" type="hidden"/> | ||
<input id="longitude" name="place[longitude]" type="hidden"/> | ||
<input type="submit" value="Share!"/> | ||
</form> | ||
|
||
<div id="map_canvas"></div><br/> | ||
|
||
<script type="text/javascript"> | ||
function fill_map() | ||
{ | ||
<% @places.each do |place| %> | ||
var location = new google.maps.LatLng(<%= place.latitude %>, <%= place.longitude %>); | ||
var marker = new_marker(); | ||
marker.setPosition(location); | ||
marker.setTitle("The beer rate here is: <%= place.rate %>"); | ||
<% end %> | ||
} | ||
</script> | ||
|
||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<%= form_for(@place) do |f| %> | ||
<% if @place.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@place.errors.count, "error") %> prohibited this place from being saved:</h2> | ||
|
||
<ul> | ||
<% @place.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :address %><br /> | ||
<%= f.text_field :address %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :rate %><br /> | ||
<%= f.number_field :rate %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :latitude %><br /> | ||
<%= f.text_field :latitude %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :longitude %><br /> | ||
<%= f.text_field :longitude %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing place</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Show', @place %> | | ||
<%= link_to 'Back', places_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<h1>Listing places</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Address</th> | ||
<th>Rate</th> | ||
<th>Latitude</th> | ||
<th>Longitude</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
|
||
<% @places.each do |place| %> | ||
<tr> | ||
<td><%= place.address %></td> | ||
<td><%= place.rate %></td> | ||
<td><%= place.latitude %></td> | ||
<td><%= place.longitude %></td> | ||
<td><%= link_to 'Show', place %></td> | ||
<td><%= link_to 'Edit', edit_place_path(place) %></td> | ||
<td><%= link_to 'Destroy', place, confirm: 'Are you sure?', method: :delete %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New Place', new_place_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New place</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Back', places_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<b>Address:</b> | ||
<%= @place.address %> | ||
</p> | ||
|
||
<p> | ||
<b>Rate:</b> | ||
<%= @place.rate %> | ||
</p> | ||
|
||
<p> | ||
<b>Latitude:</b> | ||
<%= @place.latitude %> | ||
</p> | ||
|
||
<p> | ||
<b>Longitude:</b> | ||
<%= @place.longitude %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_place_path(@place) %> | | ||
<%= link_to 'Back', places_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class CreatePlaces < ActiveRecord::Migration | ||
def change | ||
create_table :places do |t| | ||
t.string :address | ||
t.integer :rate | ||
t.float :latitude | ||
t.float :longitude | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Oops, something went wrong.