Permalink
Browse files

Modify top#created method

  • Loading branch information...
1 parent 0f94c55 commit 603add15f0384bf43e25e5125bc995703724e863 u1 committed Oct 8, 2012
View
22 app/controllers/maps_controller.rb
@@ -1,4 +1,26 @@
class MapsController < ApplicationController
+
+ def create
+ @user = User.new
+ if request.mobile?
+ @user.lat = request.mobile.position.lat
+ @user.lon = request.mobile.position.lon
+ else
+ render action: "create"
+ end
+
+ @map = Map.new
+ @map.key = UUIDTools::UUID.random_create.to_s()
+ if @map.save
+ @user.map_id = @map.id
+ if @user.save
+ return
+ end
+ end
+ # error
+ render action: "create"
+ end
+
def show
View
22 app/controllers/top_controller.rb
@@ -2,27 +2,7 @@ class TopController < ApplicationController
def index
end
- def create
+ def start
end
- def created
- @user = User.new
- if request.mobile?
- @user.lat = request.mobile.position.lat
- @user.lon = request.mobile.position.lon
- else
- render action: "create"
- end
-
- @map = Map.new
- @map.key = UUIDTools::UUID.random_create.to_s()
- if @map.save
- @user.map_id = @map.id
- if @user.save
- return
- end
- end
- # error
- render action: "create"
- end
end
View
2 app/views/maps/create.html.erb
@@ -0,0 +1,2 @@
+<h1>Maps#create</h1>
+<p>Find me in app/views/maps/create.html.erb</p>
View
5 app/views/maps/create_mobile.html.erb
@@ -0,0 +1,5 @@
+<h1>Maps#create Mobile</h1>
+<p>lat=<%= @user.lat -%>, lon=<%= @user.lon -%></p>
+<div><img src="http://maps.google.com/maps/api/staticmap?zoom=16&center=<%= @user.lat -%>,<%= @user.lon -%>&size=240x240&sensor=true&mobile=true&markers=<%= @user.lat -%>,<%= @user.lon -%>" alt="map" width="240" height="240"></div>
+<br>
+<a href="mailto:?subject=subject&amp;body=http://u1fukui.com:3000/maps/<%= @map.key -%>">send mail</a>
View
2 app/views/top/index_mobile.html.erb
@@ -1,2 +1,2 @@
<h1>Top#index Mobile</h1>
-<p><%= link_to "create map", "/create" -%></p>
+<p><%= link_to "create map", "/start" -%></p>
View
2 app/views/top/start.html
@@ -0,0 +1,2 @@
+<h1>Top#start</h1>
+<p>Find me in app/views/top/start.html.erb</p>
View
2 app/views/top/start_mobile.html
@@ -0,0 +1,2 @@
+<h1>Top#start Mobile</h1>
+<p><%= get_position_link_to("get position", "/maps/create") -%></p>
View
4 config/routes.rb
@@ -1,6 +1,6 @@
Machisuke::Application.routes.draw do
root :to => "top#index"
- get "/create" => "top#create"
- get "/created" => "top#created"
+ get "/start" => "top#start"
+ get "/maps/create" => "maps#create"
get "/maps/:key" => "maps#show"
end

0 comments on commit 603add1

Please sign in to comment.