Finding your location: checking...
+diff --git a/Gemfile b/Gemfile index 7764763..d8a3997 100644 --- a/Gemfile +++ b/Gemfile @@ -5,8 +5,16 @@ gem 'rails', '3.2.2' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' -gem 'sqlite3' +group :development do + gem 'sqlite3' +end + +group :production do + gem 'pg' +end + +gem 'devise' # Gems used only for assets and not required # in production environments by default. @@ -21,6 +29,8 @@ group :assets do end gem 'jquery-rails' +gem 'cleditor_rails' +gem 'paperclip' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' @@ -35,4 +45,4 @@ gem 'jquery-rails' # gem 'capistrano' # To use debugger -# gem 'ruby-debug19', :require => 'ruby-debug' +# gem 'ruby-debug19', :require => 'ruby-debug' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 81a3ba7..f5d7ac6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,7 +29,11 @@ GEM i18n (~> 0.6) multi_json (~> 1.0) arel (3.0.2) + bcrypt-ruby (3.0.1) + bcrypt-ruby (3.0.1-x86-mingw32) builder (3.0.0) + cleditor_rails (0.0.3) + cocaine (0.2.1) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) @@ -37,6 +41,11 @@ GEM coffee-script-source execjs coffee-script-source (1.2.0) + devise (2.0.4) + bcrypt-ruby (~> 3.0) + orm_adapter (~> 0.0.3) + railties (~> 3.1) + warden (~> 1.1.1) erubis (2.7.0) execjs (1.3.0) multi_json (~> 1.0) @@ -53,6 +62,14 @@ GEM treetop (~> 1.4.8) mime-types (1.17.2) multi_json (1.1.0) + orm_adapter (0.0.7) + paperclip (2.4.5) + activerecord (>= 2.3.0) + activesupport (>= 2.3.2) + cocaine (>= 0.0.2) + mime-types + pg (0.13.2) + pg (0.13.2-x86-mingw32) polyglot (0.3.3) rack (1.4.1) rack-cache (1.2) @@ -89,6 +106,7 @@ GEM rack (~> 1.0) tilt (~> 1.1, != 1.3.0) sqlite3 (1.3.5) + sqlite3 (1.3.5-x86-mingw32) thor (0.14.6) tilt (1.3.3) treetop (1.4.10) @@ -98,13 +116,20 @@ GEM uglifier (1.2.3) execjs (>= 0.3.0) multi_json (>= 1.0.2) + warden (1.1.1) + rack (>= 1.0) PLATFORMS ruby + x86-mingw32 DEPENDENCIES + cleditor_rails coffee-rails (~> 3.2.1) + devise jquery-rails + paperclip + pg rails (= 3.2.2) sass-rails (~> 3.2.3) sqlite3 diff --git a/app/assets/images/arbol1.png b/app/assets/images/arbol1.png new file mode 100644 index 0000000..6affc09 Binary files /dev/null and b/app/assets/images/arbol1.png differ diff --git a/app/assets/images/bea.JPG b/app/assets/images/bea.JPG new file mode 100644 index 0000000..0194842 Binary files /dev/null and b/app/assets/images/bea.JPG differ diff --git a/app/assets/images/blue-marker.png b/app/assets/images/blue-marker.png new file mode 100644 index 0000000..e905e2e Binary files /dev/null and b/app/assets/images/blue-marker.png differ diff --git a/app/assets/images/florencia.png b/app/assets/images/florencia.png new file mode 100644 index 0000000..6398a2e Binary files /dev/null and b/app/assets/images/florencia.png differ diff --git a/app/assets/images/fot.jpg b/app/assets/images/fot.jpg new file mode 100644 index 0000000..49fc1c9 Binary files /dev/null and b/app/assets/images/fot.jpg differ diff --git a/app/assets/images/logo3.png b/app/assets/images/logo3.png new file mode 100644 index 0000000..bfa4c13 Binary files /dev/null and b/app/assets/images/logo3.png differ diff --git a/app/assets/images/pablo.jpg b/app/assets/images/pablo.jpg new file mode 100644 index 0000000..b66bf26 Binary files /dev/null and b/app/assets/images/pablo.jpg differ diff --git a/app/assets/images/paris.JPG b/app/assets/images/paris.JPG new file mode 100644 index 0000000..9092cc1 Binary files /dev/null and b/app/assets/images/paris.JPG differ diff --git a/app/assets/images/pedriza.png b/app/assets/images/pedriza.png new file mode 100644 index 0000000..8d300fb Binary files /dev/null and b/app/assets/images/pedriza.png differ diff --git a/app/assets/images/pergamo.png b/app/assets/images/pergamo.png new file mode 100644 index 0000000..7e462c2 Binary files /dev/null and b/app/assets/images/pergamo.png differ diff --git a/app/assets/images/reichstag.png b/app/assets/images/reichstag.png new file mode 100644 index 0000000..8b95380 Binary files /dev/null and b/app/assets/images/reichstag.png differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 9097d83..fbc4bb2 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -11,5 +11,6 @@ // GO AFTER THE REQUIRES BELOW. // //= require jquery +//= require cleditor //= require jquery_ujs -//= require_tree . +// require_tree . diff --git a/app/assets/javascripts/application.js~ b/app/assets/javascripts/application.js~ new file mode 100644 index 0000000..ab2116a --- /dev/null +++ b/app/assets/javascripts/application.js~ @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// the compiled file. +// +// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD +// GO AFTER THE REQUIRES BELOW. +// +//= require jquery +//= require cleditor +//= require jquery_ujs + diff --git a/app/assets/javascripts/coments.form.geolocation.js b/app/assets/javascripts/coments.form.geolocation.js new file mode 100644 index 0000000..0b7aca0 --- /dev/null +++ b/app/assets/javascripts/coments.form.geolocation.js @@ -0,0 +1,57 @@ +function success(position) { + + if (document.getElementById('coment_latitude').value == ""){ + document.getElementById('coment_latitude').value=position.coords.latitude; + document.getElementById('coment_longitude').value=position.coords.longitude; + document.getElementById('coment_zoom').value=15; + } + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + s.innerHTML = position.coords.latitude+","+position.coords.longitude; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); + var myOptions = { + zoom: 15, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(success, error); +} else { + error('not supported'); +} + + + diff --git a/app/assets/javascripts/coments.geolocation.js~ b/app/assets/javascripts/coments.geolocation.js~ new file mode 100644 index 0000000..38b2521 --- /dev/null +++ b/app/assets/javascripts/coments.geolocation.js~ @@ -0,0 +1,56 @@ +function success(position) { + + if (document.getElementById('coment_latitude').value == ""){ + document.getElementById('coment_latitude').value=position.coords.latitude; + document.getElementById('coment_longitude').value=position.coords.longitude; + } + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + s.innerHTML = position.coords.latitude+","+position.coords.longitude; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); + var myOptions = { + zoom: 15, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(success, error); +} else { + error('not supported'); +} + + + diff --git a/app/assets/javascripts/coments.js.coffee b/app/assets/javascripts/coments.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/coments.js.coffee @@ -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/ diff --git a/app/assets/javascripts/geolocation.js~ b/app/assets/javascripts/geolocation.js~ new file mode 100644 index 0000000..b976519 --- /dev/null +++ b/app/assets/javascripts/geolocation.js~ @@ -0,0 +1,53 @@ +function success(position) { + document.getElementById('coment_latitude').value=position.coords.latitude; + document.getElementById('coment_longitude').value=position.coords.longitude; + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + s.innerHTML = "found you!"; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); + var myOptions = { + zoom: 15, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(success, error); +} else { + error('not supported'); +} + + + diff --git a/app/assets/javascripts/planet.js.coffee b/app/assets/javascripts/planet.js.coffee index 7615679..2a5d841 100644 --- a/app/assets/javascripts/planet.js.coffee +++ b/app/assets/javascripts/planet.js.coffee @@ -1,3 +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/ +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ \ No newline at end of file diff --git a/app/assets/javascripts/sites.coments.show.geolocation.js b/app/assets/javascripts/sites.coments.show.geolocation.js new file mode 100644 index 0000000..6e506a0 --- /dev/null +++ b/app/assets/javascripts/sites.coments.show.geolocation.js @@ -0,0 +1,22 @@ +function posicionar(position) { + document.getElementById('coment_latitude').value=position.coords.latitude; + document.getElementById('coment_longitude').value=position.coords.longitude; + document.getElementById('coment_zoom').value=15; +} + +function error_posicionar(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(posicionar, error_posicionar); +} else { + error('not supported'); +} + + + diff --git a/app/assets/javascripts/sites.form.geolocation.js b/app/assets/javascripts/sites.form.geolocation.js new file mode 100644 index 0000000..d97d497 --- /dev/null +++ b/app/assets/javascripts/sites.form.geolocation.js @@ -0,0 +1,56 @@ +function success(position) { + if (document.getElementById('site_latitude').value == ""){ + document.getElementById('site_latitude').value=position.coords.latitude; + document.getElementById('site_longitude').value=position.coords.longitude; + document.getElementById('site_zoom').value=15; + } + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + s.innerHTML = "found you!"; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); + var myOptions = { + zoom: 15, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(success, error); +} else { + error('not supported'); +} + + + diff --git a/app/assets/javascripts/sites.form.geolocation.js~ b/app/assets/javascripts/sites.form.geolocation.js~ new file mode 100644 index 0000000..49c5c72 --- /dev/null +++ b/app/assets/javascripts/sites.form.geolocation.js~ @@ -0,0 +1,53 @@ +function success(position) { + document.getElementById('site_latitude').value=position.coords.latitude; + document.getElementById('site_longitude').value=position.coords.longitude; + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + s.innerHTML = "found you!"; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); + var myOptions = { + zoom: 15, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(success, error); +} else { + error('not supported'); +} + + + diff --git a/app/assets/javascripts/sites.geolocation.js b/app/assets/javascripts/sites.geolocation.js new file mode 100644 index 0000000..49c5c72 --- /dev/null +++ b/app/assets/javascripts/sites.geolocation.js @@ -0,0 +1,53 @@ +function success(position) { + document.getElementById('site_latitude').value=position.coords.latitude; + document.getElementById('site_longitude').value=position.coords.longitude; + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + s.innerHTML = "found you!"; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); + var myOptions = { + zoom: 15, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(success, error); +} else { + error('not supported'); +} + + + diff --git a/app/assets/javascripts/sites.geolocation.js~ b/app/assets/javascripts/sites.geolocation.js~ new file mode 100644 index 0000000..b976519 --- /dev/null +++ b/app/assets/javascripts/sites.geolocation.js~ @@ -0,0 +1,53 @@ +function success(position) { + document.getElementById('coment_latitude').value=position.coords.latitude; + document.getElementById('coment_longitude').value=position.coords.longitude; + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + s.innerHTML = "found you!"; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); + var myOptions = { + zoom: 15, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(success, error); +} else { + error('not supported'); +} + + + diff --git a/app/assets/javascripts/sites.get.coordenates.js b/app/assets/javascripts/sites.get.coordenates.js new file mode 100644 index 0000000..e47ab15 --- /dev/null +++ b/app/assets/javascripts/sites.get.coordenates.js @@ -0,0 +1,10 @@ +function get_site_coordenates(){ + var address = document.getElementById('site_name').value; + var latitude = $.get("/planet/jsonp?address="+address+"&coor=lat", function(data){ + document.getElementById('site_latitude').value = $.trim(data); +}); + var longitude = $.get("/planet/jsonp?address="+address+"&coor=lng", function(data){ + document.getElementById('site_longitude').value = $.trim(data); +}); + +} diff --git a/app/assets/javascripts/sites.js.coffee b/app/assets/javascripts/sites.js.coffee new file mode 100644 index 0000000..2a5d841 --- /dev/null +++ b/app/assets/javascripts/sites.js.coffee @@ -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/ \ No newline at end of file diff --git a/app/assets/javascripts/sites.map.js~ b/app/assets/javascripts/sites.map.js~ new file mode 100644 index 0000000..fc022f0 --- /dev/null +++ b/app/assets/javascripts/sites.map.js~ @@ -0,0 +1,54 @@ +function success(position) { + document.getElementById('coment_latitude').value=position.coords.latitude; + document.getElementById('coment_longitude').value=position.coords.longitude; + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + s.innerHTML = "found you!"; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); + var myOptions = { + zoom: 15, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here! (at least within a "+position.coords.accuracy+" meter radius)" + }); +} + +function error(msg) { + var s = document.querySelector('#status'); + s.innerHTML = typeof msg == 'string' ? msg : "failed"; + s.className = 'fail'; + + // console.log(arguments); +} + +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(success, error); +} else { + error('not supported'); +} + + + + diff --git a/app/assets/javascripts/sites.show.geolocation.js b/app/assets/javascripts/sites.show.geolocation.js new file mode 100644 index 0000000..270eb35 --- /dev/null +++ b/app/assets/javascripts/sites.show.geolocation.js @@ -0,0 +1,54 @@ +function success() { + + var latitude = parseFloat(document.getElementById('latitude').value); + var longitude = parseFloat(document.getElementById('longitude').value); + var zoomlevel = parseFloat(document.getElementById('zoom').value); + + + + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + if(document.getElementById('latitude').value != ""){ + s.innerHTML = "Map:"; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(latitude, longitude); + var myOptions = { + zoom: zoomlevel, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here!" + }); + }else{ + s.innerHTML = "There are no coordenates to show map"; + s.className = 'success'; + } + + +} + + + + + diff --git a/app/assets/javascripts/sites.show.geolocation.js~ b/app/assets/javascripts/sites.show.geolocation.js~ new file mode 100644 index 0000000..de20eb5 --- /dev/null +++ b/app/assets/javascripts/sites.show.geolocation.js~ @@ -0,0 +1,54 @@ +function success() { + + var latitude = parseFloat(document.getElementById('latitude').value); + var longitude = parseFloat(document.getElementById('longitude').value); + var zoomlevel = parseFloat(document.getElementById('zoom').value); + + + + var s = document.querySelector('#status'); + + if (s.className == 'success') { + // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back + return; + } + + if(document.getElementById('latitude').value != ""){ + s.innerHTML = "Map:"; + s.className = 'success'; + + var mapcanvas = document.createElement('div'); + mapcanvas.id = 'mapcanvas'; + mapcanvas.style.height = '200px'; + mapcanvas.style.width = '260px'; + mapcanvas.style.text-align = 'right'; + + document.querySelector('article').appendChild(mapcanvas); + + var latlng = new google.maps.LatLng(latitude, longitude); + var myOptions = { + zoom: zoomlevel, + center: latlng, + mapTypeControl: false, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); + + var marker = new google.maps.Marker({ + position: latlng, + map: map, + title:"You are here!" + }); + }else{ + s.innerHTML = "There are no coordenates to show map"; + s.className = 'success'; + } + + +} + + + + + diff --git a/app/assets/javascripts/trips.js.coffee b/app/assets/javascripts/trips.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/trips.js.coffee @@ -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/ diff --git a/app/assets/javascripts/trips.show.geolocation.js b/app/assets/javascripts/trips.show.geolocation.js new file mode 100644 index 0000000..50b969b --- /dev/null +++ b/app/assets/javascripts/trips.show.geolocation.js @@ -0,0 +1,24 @@ +var s = document.querySelector('#status'); + + +s.innerHTML = "Map:"; +s.className = 'success'; + +var mapcanvas = document.createElement('div'); +mapcanvas.id = 'mapcanvas'; +mapcanvas.style.height = '200px'; +mapcanvas.style.width = '67%'; + + +document.querySelector('article').appendChild(mapcanvas); + +var latlng = new google.maps.LatLng(40, -3); + +var myOptions = { +zoom: 2, +center: latlng, +mapTypeControl: false, +navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, +mapTypeId: google.maps.MapTypeId.ROADMAP +}; +var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); diff --git a/app/assets/javascripts/visits.js.coffee b/app/assets/javascripts/visits.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/visits.js.coffee @@ -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/ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 3b5cc66..1560d8e 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -9,5 +9,6 @@ * compiled file, but it's generally better to create a new file per style scope. * *= require_self + *= require cleditor *= require_tree . -*/ +*/ \ No newline at end of file diff --git a/app/assets/stylesheets/coments.css.scss b/app/assets/stylesheets/coments.css.scss new file mode 100644 index 0000000..991976f --- /dev/null +++ b/app/assets/stylesheets/coments.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the coments controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/planet.css b/app/assets/stylesheets/planet.css new file mode 100644 index 0000000..a5690f9 --- /dev/null +++ b/app/assets/stylesheets/planet.css @@ -0,0 +1,208 @@ +/* Global styles (no utilizados de momento) */ + +#planet #notice { + color: #000; + border: 2px solid red; + padding: 1em; + margin-bottom: 2em; + background-color: #f0f0f0; + font: bold smaller sans-serif; +} + + +#planet h1 { + font: 150% sans-serif; + color: #226; + border-bottom: 3px dotted #77d; +} + +/* Styles for products/index */ + +#site .site_image { + height: 200px; + padding-top: 40px; +} + +#googlemap{ + float: right; + padding-right: 50%; +} + +#site_list table { + border-collapse: collapse; +} + +#site_list table tr td { + padding: 5px; + vertical-align: top; +} + +#site_list .list_image { + width: 60px; + height: 70px; +} + +#site_list .list_description { + width: 60%; +} + +#site_list .list_description dl { + margin: 0; +} + +#site_list .list_description dt { + color: #244; + font-weight: bold; + font-size: larger; +} + +#site_list .enlaceComentarios dt { + color: #244; + font-weight: bold; + font-size: small; +} + +#site_list .list_description dd { + margin: 0; +} + +#site_list .list_actions { + font-size: x-small; + text-align: right; + padding-left: 1em; +} +.comentarios .list_actions{ + font-size: x-small; + text-align: right; + padding-left: 1em; + float: right; +} +.comentarios{ + width: 75%; + padding: 5px; +} +.cadaComentario{ + border: solid; +} +.cadaComentario .dondeEstoy{ + font-style: italic; +} + +#site_list .list_line_even { + background: #a8b8f8; +} + +#site_list .list_line_odd { + background: #88b0f8; +} + + +/* START:mainlayout */ +/* Styles for main page */ + +#banner { + background: #668; + padding-top: 10px; + padding-bottom: 10px; + border-bottom: 2px solid; + font: small-caps 40px/40px "Times New Roman", serif; + color: #bfb; + text-align: center; +} + +#banner img { + float: left; + padding-left: 10px; +} + +#banner .user { + float: right; + color: #bfb; + font-size: small; +} + +#banner .formulario { + float: right; + padding-right:65.6%; + padding-top:10px; + color: #bfb; + font-size: small; +} + +#columns { + background: #446; +} + +#main { + margin-left: 9em; /* Ajuste de borde izquierdo */ + padding-top: 4ex; + padding-left: 2em; + background: white; +} + +#side { + float: left; + padding-top: 1em; + padding-left: 1em; + padding-bottom: 1em; + width: 8em; /* Ajuste de borde izquierdo */ + background: #446; +} + +#side a { + color: #bfb; + font-size: small; +} +/* END:mainlayout */ + +/* An entry in the store catalog (no utilizados de momento) */ + +#planet .entry { + overflow: auto; + margin-top: 1em; + border-bottom: 1px dotted #77d; +} + +#planet .name { + font-size: 120%; + font-family: sans-serif; +} + +#store .entry img { + width: 80px; + margin-right: 5px; + margin-bottom: 5px; + float: left; +} + + +#store .entry h3 { + margin-top: 0; + margin-bottom: 2px; + color: #227; +} + +#store .entry p { + margin-top: 0.5em; + margin-bottom: 0.8em; +} + +#store .entry .price_line { + clear: both; + margin-bottom: 0.5em; +} + +#store .entry .add_to_cart { + position: relative; +} + +#store .entry .price { + color: #44a; + font-weight: bold; + margin-right: 2em; +} + + +#main .visitas { + text-indent: 70%; +} \ No newline at end of file diff --git a/app/assets/stylesheets/sites.css.scss b/app/assets/stylesheets/sites.css.scss new file mode 100644 index 0000000..fa73be7 --- /dev/null +++ b/app/assets/stylesheets/sites.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the sites controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ \ No newline at end of file diff --git a/app/assets/stylesheets/trips.css.scss b/app/assets/stylesheets/trips.css.scss new file mode 100644 index 0000000..473cbc3 --- /dev/null +++ b/app/assets/stylesheets/trips.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the trips controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/visits.css.scss b/app/assets/stylesheets/visits.css.scss new file mode 100644 index 0000000..99b00b9 --- /dev/null +++ b/app/assets/stylesheets/visits.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the visits controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e8065d9..f6e5e7c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,4 @@ +# ApplicationController class ApplicationController < ActionController::Base protect_from_forgery end diff --git a/app/controllers/application_controller.rb~ b/app/controllers/application_controller.rb~ new file mode 100644 index 0000000..e8065d9 --- /dev/null +++ b/app/controllers/application_controller.rb~ @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + protect_from_forgery +end diff --git a/app/controllers/coments_controller.rb b/app/controllers/coments_controller.rb new file mode 100644 index 0000000..3740d89 --- /dev/null +++ b/app/controllers/coments_controller.rb @@ -0,0 +1,114 @@ +# ComentsController nos permite controlar las acciones relacionadas con los comentarios +# ¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show +class ComentsController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # GET /coments + # GET /coments.json + def index + + + if params[:site_id].nil? #Para que en el enlace de comentarios solo aparezcan los de el sitio en cuestión + @coments = Coment.all #si no, se pondría solo esta linea + else + @coments = Site.find(params[:site_id]).coments + end + + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @coments } + end + end + + # Muestra un comentario especifico + # GET /coments/1 + # GET /coments/1.json + def show + @coment = Coment.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @coment } + end + end + + # Nos permite crear un nuevo comentario + # GET /coments/new + # GET /coments/new.json + def new + @coment = Coment.new + #@site = Site.find(params[:site_id]) + if !params[:site_id].nil? + @site = Site.find(params[:site_id]) + end + + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @coment } + end + end + + # GET /coments/1/edit + def edit + @coment = Coment.find(params[:id]) + end + + # POST /coments + # POST /coments.json + def create + @coment = current_user.coments.build(params[:coment]) # Asigna solo si comentario asociado a current_user + + if !params[:site_id].nil? + @site = Site.find(params[:site_id]) + else + @site = Site.find(params[:coment][:site_id]) + end + @coment = @site.coments.create(params[:coment]) + + + + respond_to do |format| + if @coment.save + format.html { redirect_to site_path(@site), notice: 'Coment was successfully created.' } + format.json { render json: site_path(@site), status: :created, location: @coment } + else + format.html { render action: "new" } + format.json { render json: @coment.errors, status: :unprocessable_entity } + end + end + end + + # PUT /coments/1 + # PUT /coments/1.json + def update + @coment = current_user.coments.find(params[:id]) # busca solo en sitios asociados a current_user + # @coment = Coment.find(params[:id]) + + respond_to do |format| + if @coment.update_attributes(params[:coment]) + format.html { redirect_to @coment, notice: 'Coment was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @coment.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /coments/1 + # DELETE /coments/1.json + def destroy + @coment = current_user.coments.find(params[:id]) # busca solo en sitios asociados a current_user + # @coment = Coment.find(params[:id]) + @coment.destroy + + respond_to do |format| + format.html { redirect_to coments_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/coments_controller.rb~ b/app/controllers/coments_controller.rb~ new file mode 100644 index 0000000..4befdce --- /dev/null +++ b/app/controllers/coments_controller.rb~ @@ -0,0 +1,114 @@ +# ComentsController nos permite controlar las acciones relacionadas con los comentarios +# ¡IMPORTANTE! Necesario haber inidiado sesión con un usuario +class ComentsController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # GET /coments + # GET /coments.json + def index + + + if params[:site_id].nil? #Para que en el enlace de comentarios solo aparezcan los de el sitio en cuestión + @coments = Coment.all #si no, se pondría solo esta linea + else + @coments = Site.find(params[:site_id]).coments + end + + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @coments } + end + end + + # Muestra un comentario especifico + # GET /coments/1 + # GET /coments/1.json + def show + @coment = Coment.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @coment } + end + end + + # Nos permite crear un nuevo comentario + # GET /coments/new + # GET /coments/new.json + def new + @coment = Coment.new + #@site = Site.find(params[:site_id]) + if !params[:site_id].nil? + @site = Site.find(params[:site_id]) + end + + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @coment } + end + end + + # GET /coments/1/edit + def edit + @coment = Coment.find(params[:id]) + end + + # POST /coments + # POST /coments.json + def create + @coment = current_user.coments.build(params[:coment]) # Asigna solo si comentario asociado a current_user + + if !params[:site_id].nil? + @site = Site.find(params[:site_id]) + else + @site = Site.find(params[:coment][:site_id]) + end + @coment = @site.coments.create(params[:coment]) + + + + respond_to do |format| + if @coment.save + format.html { redirect_to site_path(@site), notice: 'Coment was successfully created.' } + format.json { render json: site_path(@site), status: :created, location: @coment } + else + format.html { render action: "new" } + format.json { render json: @coment.errors, status: :unprocessable_entity } + end + end + end + + # PUT /coments/1 + # PUT /coments/1.json + def update + @coment = current_user.coments.find(params[:id]) # busca solo en sitios asociados a current_user + # @coment = Coment.find(params[:id]) + + respond_to do |format| + if @coment.update_attributes(params[:coment]) + format.html { redirect_to @coment, notice: 'Coment was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @coment.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /coments/1 + # DELETE /coments/1.json + def destroy + @coment = current_user.coments.find(params[:id]) # busca solo en sitios asociados a current_user + # @coment = Coment.find(params[:id]) + @coment.destroy + + respond_to do |format| + format.html { redirect_to coments_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/planet_controller.rb b/app/controllers/planet_controller.rb index be7ac0a..9670007 100644 --- a/app/controllers/planet_controller.rb +++ b/app/controllers/planet_controller.rb @@ -1,11 +1,49 @@ +# PlanetController ilustra el uso de *RDoc*. La documentación de un proyecto en +# genera en el directorio *proy/doc* en formato Web con +# $proy> rake doc:app +# +# == Algunos comandos de formateo +# +# Tal y como muestra el subitulo anterior, este se define empezando la +# línea con ==. En los títulos debe empezar por =. +# +# Un [ ... ] seguido de texto define una lista titulada, como aquí +# [Clases, Módulos o Métodos] Se documentan con comentarios justo encima de sus definición, como aquí. +# +# Un * o - definen las entradas de una lista itemizada +# * Un URL se define así email[mailto:pepe@ejemplo.com] +# * o así {Pepe Rubio}[mailto:pepe@ejemplo.com] +# +# Un número o letra seguido de punto genera una lista númerada +# 1. + permite generar *negrita*, igual que con HTML +# 2. _ permite generar _cursiva_, igual que con HTML +# 3. * permite generar letra de +teletipo+, igual que con HTML +# class PlanetController < ApplicationController + + # GET /sites /search + def search + @sites = Site.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%") + @trips = Trip.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%") + end + + # Método que define una acción vacía del controlador def index end - + # Método que define una acción vacía del controlador def contact end - + # Método que define una acción vacía del controlador + def author + end + # Método que define una acción vacía del controlador def ejemplo end + + # Método para definir la acción que nos permite parsear json de la API de googlemaps + # +No renderiza el layout+ + def jsonp + render :layout => false + end end diff --git a/app/controllers/planet_controller.rb~ b/app/controllers/planet_controller.rb~ new file mode 100644 index 0000000..dd8c09a --- /dev/null +++ b/app/controllers/planet_controller.rb~ @@ -0,0 +1,49 @@ +# PlanetController ilustra el uso de *RDoc*. La documentacin de un proyecto en +# genera en el directorio *proy/doc* en formato Web con +# $proy> rake doc:app +# +# == Algunos comandos de formateo +# +# Tal y como muestra el subitulo anterior, este se define empezando la +# lnea con ==. En los ttulos debe empezar por =. +# +# Un [ ... ] seguido de texto define una lista titulada, como aqu +# [Clases, Mdulos o Mtodos] Se documentan con comentarios justo encima de sus definicin, como aqu. +# +# Un * o - definen las entradas de una lista itemizada +# * Un URL se define as email[mailto:pepe@ejemplo.com] +# * o as {Pepe Rubio}[mailto:pepe@ejemplo.com] +# +# Un nmero o letra seguido de punto genera una lista nmerada +# 1. + permite generar *negrita*, igual que con HTML +# 2. _ permite generar _cursiva_, igual que con HTML +# 3. * permite generar letra de +teletipo+, igual que con HTML +# +class PlanetController < ApplicationController + + # GET /sites /search + def search + @sites = Site.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%") + @trips = Trip.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%") + end + + # Mtodo que define una accin vaca del controlador + def index + end + # Mtodo que define una accin vaca del controlador + def contact + end + # Mtodo que define una accin vaca del controlador + def author + end + # Mtodo que define una accin vaca del controlador + def ejemplo + end + + # Mtodo para definir la accin que nos permite parsear json de la API de googlemaps + # +No renderiza el layout+ + def jsonp + render :layout => false + end + +end diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb new file mode 100644 index 0000000..43a832a --- /dev/null +++ b/app/controllers/sites_controller.rb @@ -0,0 +1,102 @@ +# SitesController nos permite controlar las acciones relacionadas con los sitios +# ¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show +class SitesController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + after_filter :count_visita, :only => :show + + + # GET /sites + # GET /sites.json + def index + if params[:type_id].nil? or params[:type_id].empty? + @sites = Site.all # path: /types + else + @sites = Type.find(params[:type_id]).sites # path: /types/id/sites + end + respond_to do |format| + format.html # index.html.erb + format.json { render json: @sites } + end + end + + # GET /sites/1 + # GET /sites/1.json + def show + @site = Site.find(params[:id]) + + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @site } + format.json { render json: @coments } + + end + end + + # GET /sites/new + # GET /sites/new.json + def new + @site = current_user.sites.build # crea sitio vacio asociado a current_user + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @site } + end + end + + # GET /sites/1/edit + def edit + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + end + + # POST /sites + # POST /sites.json + def create + @site = current_user.sites.build(params[:site]) # Asigna solo si sitio asociado a current_user + + respond_to do |format| + if @site.save + format.html { redirect_to @site, notice: 'Site was successfully created.' } + format.json { render json: @site, status: :created, location: @site } + else + format.html { render action: "new" } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end + end + + # PUT /sites/1 + # PUT /sites/1.json + def update + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + + respond_to do |format| + if @site.update_attributes(params[:site]) + format.html { redirect_to @site, notice: 'Site was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /sites/1 + # DELETE /sites/1.json + def destroy + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + @site.destroy + + respond_to do |format| + format.html { redirect_to sites_url } + format.json { head :no_content } + end + end + private + def count_visita + @site.increment!(:visitas) + end + +end diff --git a/app/controllers/sites_controller.rb~ b/app/controllers/sites_controller.rb~ new file mode 100644 index 0000000..8efd62a --- /dev/null +++ b/app/controllers/sites_controller.rb~ @@ -0,0 +1,102 @@ +# SitesController nos permite controlar las acciones relacionadas con los viajes +# ¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show +class SitesController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + after_filter :count_visita, :only => :show + + + # GET /sites + # GET /sites.json + def index + if params[:type_id].nil? or params[:type_id].empty? + @sites = Site.all # path: /types + else + @sites = Type.find(params[:type_id]).sites # path: /types/id/sites + end + respond_to do |format| + format.html # index.html.erb + format.json { render json: @sites } + end + end + + # GET /sites/1 + # GET /sites/1.json + def show + @site = Site.find(params[:id]) + + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @site } + format.json { render json: @coments } + + end + end + + # GET /sites/new + # GET /sites/new.json + def new + @site = current_user.sites.build # crea sitio vacio asociado a current_user + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @site } + end + end + + # GET /sites/1/edit + def edit + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + end + + # POST /sites + # POST /sites.json + def create + @site = current_user.sites.build(params[:site]) # Asigna solo si sitio asociado a current_user + + respond_to do |format| + if @site.save + format.html { redirect_to @site, notice: 'Site was successfully created.' } + format.json { render json: @site, status: :created, location: @site } + else + format.html { render action: "new" } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end + end + + # PUT /sites/1 + # PUT /sites/1.json + def update + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + + respond_to do |format| + if @site.update_attributes(params[:site]) + format.html { redirect_to @site, notice: 'Site was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /sites/1 + # DELETE /sites/1.json + def destroy + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + @site.destroy + + respond_to do |format| + format.html { redirect_to sites_url } + format.json { head :no_content } + end + end + private + def count_visita + @site.increment!(:visitas) + end + +end diff --git a/app/controllers/trips_controller.rb b/app/controllers/trips_controller.rb new file mode 100644 index 0000000..58d4dc7 --- /dev/null +++ b/app/controllers/trips_controller.rb @@ -0,0 +1,90 @@ +# TripsController nos permite controlar las acciones relacionadas con los viajes +# ¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show +class TripsController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # GET /trips + # GET /trips.json + def index + @trips = Trip.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @trips } + end + end + + # GET /trips/1 + # GET /trips/1.json + def show + @trip = Trip.find(params[:id]) + @visit = @trip.visits.build + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @trip } + end + end + + # GET /trips/new + # GET /trips/new.json + def new + @trip = current_user.trips.build + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @trip } + end + end + + # GET /trips/1/edit + def edit + @trip = current_user.trips.find(params[:id]) + end + + # POST /trips + # POST /trips.json + def create + @trip = current_user.trips.build(params[:trip]) + + respond_to do |format| + if @trip.save + format.html { redirect_to @trip, notice: 'Trip was successfully created.' } + format.json { render json: @trip, status: :created, location: @trip } + else + format.html { render action: "new" } + format.json { render json: @trip.errors, status: :unprocessable_entity } + end + end + end + + # PUT /trips/1 + # PUT /trips/1.json + def update + @trip = current_user.trips.find(params[:id]) + + respond_to do |format| + if @trip.update_attributes(params[:trip]) + format.html { redirect_to @trip, notice: 'Trip was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @trip.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /trips/1 + # DELETE /trips/1.json + def destroy + @trip = current_user.trips.find(params[:id]) + @trip.destroy + + respond_to do |format| + format.html { redirect_to trips_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/trips_controller.rb~ b/app/controllers/trips_controller.rb~ new file mode 100644 index 0000000..321f6e3 --- /dev/null +++ b/app/controllers/trips_controller.rb~ @@ -0,0 +1,88 @@ +class TripsController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # GET /trips + # GET /trips.json + def index + @trips = Trip.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @trips } + end + end + + # GET /trips/1 + # GET /trips/1.json + def show + @trip = Trip.find(params[:id]) + @visit = @trip.visits.build + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @trip } + end + end + + # GET /trips/new + # GET /trips/new.json + def new + @trip = current_user.trips.build + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @trip } + end + end + + # GET /trips/1/edit + def edit + @trip = current_user.trips.find(params[:id]) + end + + # POST /trips + # POST /trips.json + def create + @trip = current_user.trips.build(params[:trip]) + + respond_to do |format| + if @trip.save + format.html { redirect_to @trip, notice: 'Trip was successfully created.' } + format.json { render json: @trip, status: :created, location: @trip } + else + format.html { render action: "new" } + format.json { render json: @trip.errors, status: :unprocessable_entity } + end + end + end + + # PUT /trips/1 + # PUT /trips/1.json + def update + @trip = current_user.trips.find(params[:id]) + + respond_to do |format| + if @trip.update_attributes(params[:trip]) + format.html { redirect_to @trip, notice: 'Trip was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @trip.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /trips/1 + # DELETE /trips/1.json + def destroy + @trip = current_user.trips.find(params[:id]) + @trip.destroy + + respond_to do |format| + format.html { redirect_to trips_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rb index da826f4..0f73231 100644 --- a/app/controllers/types_controller.rb +++ b/app/controllers/types_controller.rb @@ -1,4 +1,20 @@ +# Controlador de los tipos class TypesController < ApplicationController + + # GET /types + # GET /types.json + # Devuelve una lista ordenada por nombre + def ordered_index + @types = Type.find(:all, :order => :name) + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @types } + end + end + + + # GET /types # GET /types.json def index @@ -9,6 +25,8 @@ def index format.json { render json: @types } end end + + # GET /types/1 # GET /types/1.json diff --git a/app/controllers/types_controller.rb~ b/app/controllers/types_controller.rb~ new file mode 100644 index 0000000..6520f0f --- /dev/null +++ b/app/controllers/types_controller.rb~ @@ -0,0 +1,100 @@ +# Controlador de los tipos +class TypesController < ApplicationController + + # GET /types + # GET /types.json + def ordered_index + @types = Type.find(:all, :order => :name) + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @types } + end + end + + + + # GET /types + # GET /types.json + def index + @types = Type.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @types } + end + end + + + + # GET /types/1 + # GET /types/1.json + def show + @type = Type.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @type } + end + end + + # GET /types/new + # GET /types/new.json + def new + @type = Type.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @type } + end + end + + # GET /types/1/edit + def edit + @type = Type.find(params[:id]) + end + + # POST /types + # POST /types.json + def create + @type = Type.new(params[:type]) + + respond_to do |format| + if @type.save + format.html { redirect_to @type, notice: 'Type was successfully created.' } + format.json { render json: @type, status: :created, location: @type } + else + format.html { render action: "new" } + format.json { render json: @type.errors, status: :unprocessable_entity } + end + end + end + + # PUT /types/1 + # PUT /types/1.json + def update + @type = Type.find(params[:id]) + + respond_to do |format| + if @type.update_attributes(params[:type]) + format.html { redirect_to @type, notice: 'Type was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @type.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /types/1 + # DELETE /types/1.json + def destroy + @type = Type.find(params[:id]) + @type.destroy + + respond_to do |format| + format.html { redirect_to types_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/visits_controller.rb b/app/controllers/visits_controller.rb new file mode 100644 index 0000000..b2fde8e --- /dev/null +++ b/app/controllers/visits_controller.rb @@ -0,0 +1,88 @@ +# VisitsController para las visitas +class VisitsController < ApplicationController + # GET /visits + # GET /visits.json + # Nos devuelve todas las visitas + def index + @visits = Visit.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @visits } + end + end + + # GET /visits/1 + # GET /visits/1.json + # Sólo aquella que coincide con el parámetro id + def show + @visit = Visit.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @visit } + end + end + + # GET /visits/new + # GET /visits/new.json + # Para crear una nueva visita + def new + @visit = Visit.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @visit } + end + end + + # GET /visits/1/edit + def edit + @visit = Visit.find(params[:id]) + end + + # POST /visits + # POST /visits.json + def create + @visit = Visit.new(params[:visit]) + + respond_to do |format| + if @visit.save + format.html { redirect_to @visit.trip, notice: 'Visit was successfully created.' } + format.js + format.json { render json: @visit, status: :created, location: @visit } + else + format.html { render action: "new" } + format.json { render json: @visit.errors, status: :unprocessable_entity } + end + end + end + + # PUT /visits/1 + # PUT /visits/1.json + def update + @visit = Visit.find(params[:id]) + + respond_to do |format| + if @visit.update_attributes(params[:visit]) + format.html { redirect_to @visit.trip, notice: 'Visit was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @visit.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /visits/1 + # DELETE /visits/1.json + def destroy + @visit = Visit.find(params[:id]) + @visit.destroy + + respond_to do |format| + format.html { redirect_to @visit.trip } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/visits_controller.rb~ b/app/controllers/visits_controller.rb~ new file mode 100644 index 0000000..1830f62 --- /dev/null +++ b/app/controllers/visits_controller.rb~ @@ -0,0 +1,84 @@ +class VisitsController < ApplicationController + # GET /visits + # GET /visits.json + def index + @visits = Visit.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @visits } + end + end + + # GET /visits/1 + # GET /visits/1.json + def show + @visit = Visit.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @visit } + end + end + + # GET /visits/new + # GET /visits/new.json + def new + @visit = Visit.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @visit } + end + end + + # GET /visits/1/edit + def edit + @visit = Visit.find(params[:id]) + end + + # POST /visits + # POST /visits.json + def create + @visit = Visit.new(params[:visit]) + + respond_to do |format| + if @visit.save + format.html { redirect_to @visit.trip, notice: 'Visit was successfully created.' } + format.js + format.json { render json: @visit, status: :created, location: @visit } + else + format.html { render action: "new" } + format.json { render json: @visit.errors, status: :unprocessable_entity } + end + end + end + + # PUT /visits/1 + # PUT /visits/1.json + def update + @visit = Visit.find(params[:id]) + + respond_to do |format| + if @visit.update_attributes(params[:visit]) + format.html { redirect_to @visit.trip, notice: 'Visit was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @visit.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /visits/1 + # DELETE /visits/1.json + def destroy + @visit = Visit.find(params[:id]) + @visit.destroy + + respond_to do |format| + format.html { redirect_to @visit.trip } + format.json { head :no_content } + end + end +end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..798c403 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,47 @@ +# Helpers que estarán disponibles desde todas las vistas module ApplicationHelper + +# Nos permite incluir un javascript. +# Deprecated: Usar javascript_include_tag en su lugar +def include_javascript (file) + s = " " + content_for(:head, raw(s)) +end + + + +# Nos permite obtener en formato string el nombre de la ciudad o región pasándo como parámetro latitud y longitud +def get_address(latitude,longitude) + + if (!latitude.nil?) + require 'open-uri' + require 'json' + result = JSON.parse(open("http://maps.googleapis.com/maps/api/geocode/json?latlng=#{latitude},#{longitude}&sensor=false").read) + localidad = "near "+result['results'][0]['address_components'][3]['long_name'] + else + localidad = "" + end + + localidad +end + + + +# Añade un marcador en un mapa de google +# IMPORTANTE: Ha de existir previamente un mapa en pantalla llamado 'map' +def add_gmap_marker (latitude,longitude,text) + javascript = "" + if(!latitude.nil?) + javascript = "" + end + raw(javascript) +end + end diff --git a/app/helpers/application_helper.rb~ b/app/helpers/application_helper.rb~ new file mode 100644 index 0000000..fff3c83 --- /dev/null +++ b/app/helpers/application_helper.rb~ @@ -0,0 +1,46 @@ +# Helpers que estarán disponibles desde todas las vistas +module ApplicationHelper + +def include_javascript (file) + s = " " + content_for(:head, raw(s)) +end + + + + +def get_address(latitude,longitude) + + if (!latitude.nil?) + require 'open-uri' + require 'json' + result = JSON.parse(open("http://maps.googleapis.com/maps/api/geocode/json?latlng=#{latitude},#{longitude}&sensor=false").read) + localidad = "near "+result['results'][0]['address_components'][3]['long_name'] + else + localidad = "" + end + + localidad +end + + + + + + +def add_gmap_marker (latitude,longitude,text) + javascript = "" + if(!latitude.nil?) + javascript = "" + end + raw(javascript) +end + +end diff --git a/app/helpers/coments_helper.rb b/app/helpers/coments_helper.rb new file mode 100644 index 0000000..31dd4b5 --- /dev/null +++ b/app/helpers/coments_helper.rb @@ -0,0 +1,5 @@ +# No se usa +module ComentsHelper + + +end diff --git a/app/helpers/coments_helper.rb~ b/app/helpers/coments_helper.rb~ new file mode 100644 index 0000000..0113d79 --- /dev/null +++ b/app/helpers/coments_helper.rb~ @@ -0,0 +1,4 @@ +module ComentsHelper + + +end diff --git a/app/helpers/planet_helper.rb b/app/helpers/planet_helper.rb index 5bbc197..e74867c 100644 --- a/app/helpers/planet_helper.rb +++ b/app/helpers/planet_helper.rb @@ -1,2 +1,3 @@ +# No se usa module PlanetHelper end diff --git a/app/helpers/planet_helper.rb~ b/app/helpers/planet_helper.rb~ new file mode 100644 index 0000000..5bbc197 --- /dev/null +++ b/app/helpers/planet_helper.rb~ @@ -0,0 +1,2 @@ +module PlanetHelper +end diff --git a/app/helpers/sites_helper.rb b/app/helpers/sites_helper.rb new file mode 100644 index 0000000..715d58f --- /dev/null +++ b/app/helpers/sites_helper.rb @@ -0,0 +1,7 @@ +module SitesHelper + def new_gmap(latitude,longitude,zoom) + + end + + +end diff --git a/app/helpers/sites_helper.rb~ b/app/helpers/sites_helper.rb~ new file mode 100644 index 0000000..10a1ce9 --- /dev/null +++ b/app/helpers/sites_helper.rb~ @@ -0,0 +1,16 @@ +module SitesHelper + def new_gmap(latitude,longitude,zoom) + + end + + def get_address(latitude,longitude) + if (!latitude.nil?) + result = JSON.parse(open("http://maps.googleapis.com/maps/api/geocode/json?latlng=#{latitude},#{longitude}&sensor=false").read) + localidad = "near "+result['results'][0]['address_components'][3]['long_name'] + else + localidad = "" + end + + localidad + end +end diff --git a/app/helpers/trips_helper.rb b/app/helpers/trips_helper.rb new file mode 100644 index 0000000..d0c1ee0 --- /dev/null +++ b/app/helpers/trips_helper.rb @@ -0,0 +1,3 @@ +# No se usa +module TripsHelper +end diff --git a/app/helpers/trips_helper.rb~ b/app/helpers/trips_helper.rb~ new file mode 100644 index 0000000..04f333d --- /dev/null +++ b/app/helpers/trips_helper.rb~ @@ -0,0 +1,2 @@ +module TripsHelper +end diff --git a/app/helpers/visits_helper.rb b/app/helpers/visits_helper.rb new file mode 100644 index 0000000..83968ef --- /dev/null +++ b/app/helpers/visits_helper.rb @@ -0,0 +1,3 @@ +# No se usa +module VisitsHelper +end diff --git a/app/helpers/visits_helper.rb~ b/app/helpers/visits_helper.rb~ new file mode 100644 index 0000000..8ce5f83 --- /dev/null +++ b/app/helpers/visits_helper.rb~ @@ -0,0 +1,2 @@ +module VisitsHelper +end diff --git a/app/models/coment.rb b/app/models/coment.rb new file mode 100644 index 0000000..3e645e5 --- /dev/null +++ b/app/models/coment.rb @@ -0,0 +1,15 @@ +class Coment < ActiveRecord::Base + belongs_to :site + belongs_to :user + + # Debe estar protegido para evitar accesos indeseados + #attr_protected :user_id + + # Se aaden estas definiciones + + validates :site_id, :presence => true + validates :user_id, :presence => true + validates :coment, :presence => true, + :length => { :maximum => 240 } + +end diff --git a/app/models/site.rb b/app/models/site.rb new file mode 100644 index 0000000..9b3ad0b --- /dev/null +++ b/app/models/site.rb @@ -0,0 +1,15 @@ +class Site < ActiveRecord::Base + belongs_to :type + belongs_to :user + has_many :visits + has_many :coments + has_many :trips, :through => :visits + has_attached_file :image + + + # Debe estar protegido para evitar accesos indeseados + attr_protected :user_id + + # Se aaden estas definiciones + validates :name, :type_id, :presence => true # campo obligatorio +end \ No newline at end of file diff --git a/app/models/trip.rb b/app/models/trip.rb new file mode 100644 index 0000000..4ff6d83 --- /dev/null +++ b/app/models/trip.rb @@ -0,0 +1,7 @@ +class Trip < ActiveRecord::Base + belongs_to :user + has_many :visits + has_many :sites, :through => :visits + + attr_protected :user_id # por seguridad +end diff --git a/app/models/type.rb b/app/models/type.rb index e89da76..a1853a0 100644 --- a/app/models/type.rb +++ b/app/models/type.rb @@ -1,2 +1,8 @@ class Type < ActiveRecord::Base -end + has_many :sites + + + # Se aade esta definicin de recurso + validates :name, :description, :presence => true # campo obligatorio + validates :name, :uniqueness => true # Campo nico (no repetido) +end \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..d0bacef --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,16 @@ +class User < ActiveRecord::Base + + has_many :sites + has_many :trips + has_many :coments + + # Include default devise modules. Others available are: + # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable + devise :database_authenticatable, :registerable, + :recoverable, :rememberable, :trackable, :validatable + + validates_presence_of :name + + # Setup accessible (or protected) attributes for your model + attr_accessible :name, :email, :password, :password_confirmation, :remember_me +end \ No newline at end of file diff --git a/app/models/visit.rb b/app/models/visit.rb new file mode 100644 index 0000000..57546da --- /dev/null +++ b/app/models/visit.rb @@ -0,0 +1,4 @@ +class Visit < ActiveRecord::Base + belongs_to :trip + belongs_to :site +end diff --git a/app/views/coments/_form.html.erb b/app/views/coments/_form.html.erb new file mode 100644 index 0000000..be65978 --- /dev/null +++ b/app/views/coments/_form.html.erb @@ -0,0 +1,54 @@ +<%= javascript_include_tag 'http://maps.google.com/maps/api/js?sensor=false' %> +<%= javascript_include_tag 'coments.form.geolocation' %> + + + +<%= form_for(@coment) do |f| %> + <% if @coment.errors.any? %> +
Finding your location: checking...
+Finding your location: checking...
++
+
<%= notice %>
+ ++ Coment: + <%= @coment.coment %> +
+ ++ User: + <%= @coment.user.name if @coment.user %> +
+ ++ Site: + <%= @coment.site.name if @coment.site %> +
+ + +<%= link_to 'Edit', edit_coment_path(@coment) %> | +<%= link_to 'Back', coments_path %> diff --git a/app/views/devise/_links.erb b/app/views/devise/_links.erb new file mode 100644 index 0000000..eab783a --- /dev/null +++ b/app/views/devise/_links.erb @@ -0,0 +1,25 @@ +<%- if controller_name != 'sessions' %> + <%= link_to "Sign in", new_session_path(resource_name) %>Welcome <%= @resource.email %>!
+ +You can confirm your account email through the link below:
+ +<%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %>
diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb new file mode 100644 index 0000000..ae9e888 --- /dev/null +++ b/app/views/devise/mailer/reset_password_instructions.html.erb @@ -0,0 +1,8 @@ +Hello <%= @resource.email %>!
+ +Someone has requested a link to change your password, and you can do this through the link below.
+ +<%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %>
+ +If you didn't request this, please ignore this email.
+Your password won't change until you access the link above and create a new one.
diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb new file mode 100644 index 0000000..2263c21 --- /dev/null +++ b/app/views/devise/mailer/unlock_instructions.html.erb @@ -0,0 +1,7 @@ +Hello <%= @resource.email %>!
+ +Your account has been locked due to an excessive amount of unsuccessful sign in attempts.
+ +Click the link below to unlock your account:
+ +<%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %>
diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb new file mode 100644 index 0000000..5f7bcf8 --- /dev/null +++ b/app/views/devise/passwords/edit.html.erb @@ -0,0 +1,16 @@ +<%= f.label :name %>
<%= f.text_field :name %>
Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.
+ +<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb new file mode 100644 index 0000000..79a8c31 --- /dev/null +++ b/app/views/devise/registrations/new.html.erb @@ -0,0 +1,19 @@ +<%= f.label :name %>
<%= f.text_field :name %>
+ <%= image_tag('bea.JPG') %> +
+ <%= image_tag('pablo.jpg') %> +
To contact us send us an email to:
or call us at: 615 783 567
\ No newline at end of file +To contact us send us an email to:
or call us at: 615 783 567
Helpers que estarán disponibles desde todas las vistas
+ +Añade un marcador en un mapa de google
+ +IMPORTANTE: Ha de existir previamente un mapa en pantalla llamado 'map'+ + + +
# File app/helpers/application_helper.rb, line 32 +def add_gmap_marker (latitude,longitude,text) + javascript = "" + if(!latitude.nil?) + javascript = "<script> + latlng = new google.maps.LatLng(#{latitude}, #{longitude}); + marker = new google.maps.Marker({ + position: latlng, + map: map, + title:'#{text}' + }); + </script>" + end + raw(javascript) +end+
Nos permite obtener en formato string el nombre de la ciudad o región +pasándo como parámetro latitud y longitud
+ + + +# File app/helpers/application_helper.rb, line 14 +def get_address(latitude,longitude) + + if (!latitude.nil?) + require 'open-uri' + require 'json' + result = JSON.parse(open("http://maps.googleapis.com/maps/api/geocode/json?latlng=#{latitude},#{longitude}&sensor=false").read) + localidad = "near "+result['results'][0]['address_components'][3]['long_name'] + else + localidad = "" + end + + localidad +end+
Nos permite incluir un javascript.
+ +Deprecated: Usar javascript_include_tag en su lugar+ + + +
# File app/helpers/application_helper.rb, line 6 +def include_javascript (file) + s = " <script type=\"text/javascript\">" + render(:file => file) + "</script>" + content_for(:head, raw(s)) +end+
ComentsController nos permite +controlar las acciones relacionadas con los comentarios
+ +¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show+ +
POST /coments POST /coments.json
+ + + +# File app/controllers/coments_controller.rb, line 62 +def create + @coment = current_user.coments.build(params[:coment]) # Asigna solo si comentario asociado a current_user + + if !params[:site_id].nil? + @site = Site.find(params[:site_id]) + else + @site = Site.find(params[:coment][:site_id]) + end + @coment = @site.coments.create(params[:coment]) + + + + respond_to do |format| + if @coment.save + format.html { redirect_to site_path(@site), notice: 'Coment was successfully created.' } + format.json { render json: site_path(@site), status: :created, location: @coment } + else + format.html { render action: "new" } + format.json { render json: @coment.errors, status: :unprocessable_entity } + end + end +end+
DELETE /coments/1 DELETE /coments/1.json
+ + + +# File app/controllers/coments_controller.rb, line 104 +def destroy + @coment = current_user.coments.find(params[:id]) # busca solo en sitios asociados a current_user +# @coment = Coment.find(params[:id]) + @coment.destroy + + respond_to do |format| + format.html { redirect_to coments_url } + format.json { head :no_content } + end +end+
GET /coments/1/edit
+ + + +# File app/controllers/coments_controller.rb, line 56 +def edit + @coment = Coment.find(params[:id]) +end+
GET /coments GET /coments.json
+ + + +# File app/controllers/coments_controller.rb, line 10 +def index + + + if params[:site_id].nil? #Para que en el enlace de comentarios solo aparezcan los de el sitio en cuestión + @coments = Coment.all #si no, se pondría solo esta linea + else + @coments = Site.find(params[:site_id]).coments + end + + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @coments } + end +end+
Nos permite crear un nuevo comentario GET /coments/new GET +/coments/new.json
+ + + +# File app/controllers/coments_controller.rb, line 41 +def new + @coment = Coment.new + #@site = Site.find(params[:site_id]) + if !params[:site_id].nil? + @site = Site.find(params[:site_id]) + end + + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @coment } + end +end+
Muestra un comentario especifico GET /coments/1 GET /coments/1.json
+ + + +# File app/controllers/coments_controller.rb, line 29 +def show + @coment = Coment.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @coment } + end +end+
PUT /coments/1 PUT /coments/1.json
+ + + +# File app/controllers/coments_controller.rb, line 87 +def update + @coment = current_user.coments.find(params[:id]) # busca solo en sitios asociados a current_user + # @coment = Coment.find(params[:id]) + + respond_to do |format| + if @coment.update_attributes(params[:coment]) + format.html { redirect_to @coment, notice: 'Coment was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @coment.errors, status: :unprocessable_entity } + end + end +end+
No se usa
+ +PlanetController ilustra el uso de +RDoc. La documentación de un proyecto en genera en el +directorio proy/doc en formato Web con
+ +$proy> rake doc:app+ +
Tal y como muestra el subitulo anterior, este se define empezando la línea +con ==. En los títulos debe empezar por =.
+ +Un [ … ] seguido de texto define una lista titulada, como aquí
+Se documentan con comentarios justo encima de sus definición, como aquí.
+Un * o - definen las entradas de una lista itemizada
+Un URL se define así email
+o así Pepe Rubio
+Un número o letra seguido de punto genera una lista númerada
++ permite generar negrita, igual que con +HTML
+_ permite generar cursiva, igual que con HTML
+permite generar letra de teletipo, igual que con
+HTML
Método que define una acción vacía del controlador
+ + + +# File app/controllers/planet_controller.rb, line 34 +def contact +end+
Método que define una acción vacía del controlador
+ + + +# File app/controllers/planet_controller.rb, line 40 +def ejemplo +end+
Método que define una acción vacía del controlador
+ + + +# File app/controllers/planet_controller.rb, line 31 +def index +end+
Método para definir la acción que nos permite parsear json de la API de +googlemaps +No renderiza el layout+
+ + + +# File app/controllers/planet_controller.rb, line 45 + def jsonp + render :layout => false +end+
GET /sites /search
+ + + +# File app/controllers/planet_controller.rb, line 25 +def search + @sites = Site.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%") + @trips = Trip.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%") +end+
No se usa
+ +SitesController nos permite controlar +las acciones relacionadas con los sitios
+ +¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show+ +
POST /sites POST /sites.json
+ + + +# File app/controllers/sites_controller.rb, line 56 +def create + @site = current_user.sites.build(params[:site]) # Asigna solo si sitio asociado a current_user + + respond_to do |format| + if @site.save + format.html { redirect_to @site, notice: 'Site was successfully created.' } + format.json { render json: @site, status: :created, location: @site } + else + format.html { render action: "new" } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end +end+
DELETE /sites/1 DELETE /sites/1.json
+ + + +# File app/controllers/sites_controller.rb, line 88 +def destroy + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + @site.destroy + + respond_to do |format| + format.html { redirect_to sites_url } + format.json { head :no_content } + end +end+
GET /sites/1/edit
+ + + +# File app/controllers/sites_controller.rb, line 50 +def edit + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user +end+
GET /sites GET /sites.json
+ + + +# File app/controllers/sites_controller.rb, line 12 +def index + if params[:type_id].nil? or params[:type_id].empty? + @sites = Site.all # path: /types + else + @sites = Type.find(params[:type_id]).sites # path: /types/id/sites + end + respond_to do |format| + format.html # index.html.erb + format.json { render json: @sites } + end +end+
GET /sites/new GET /sites/new.json
+ + + +# File app/controllers/sites_controller.rb, line 40 +def new + @site = current_user.sites.build # crea sitio vacio asociado a current_user + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @site } + end +end+
GET /sites/1 GET /sites/1.json
+ + + +# File app/controllers/sites_controller.rb, line 26 +def show + @site = Site.find(params[:id]) + + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @site } + format.json { render json: @coments } + + end +end+
PUT /sites/1 PUT /sites/1.json
+ + + +# File app/controllers/sites_controller.rb, line 72 +def update + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + + respond_to do |format| + if @site.update_attributes(params[:site]) + format.html { redirect_to @site, notice: 'Site was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end +end+
# File app/helpers/sites_helper.rb, line 2 +def new_gmap(latitude,longitude,zoom) + +end+
ActiveRecord::Base + +
TripsController nos permite controlar +las acciones relacionadas con los viajes
+ +¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show+ +
POST /trips POST /trips.json
+ + + +# File app/controllers/trips_controller.rb, line 49 +def create + @trip = current_user.trips.build(params[:trip]) + + respond_to do |format| + if @trip.save + format.html { redirect_to @trip, notice: 'Trip was successfully created.' } + format.json { render json: @trip, status: :created, location: @trip } + else + format.html { render action: "new" } + format.json { render json: @trip.errors, status: :unprocessable_entity } + end + end +end+
DELETE /trips/1 DELETE /trips/1.json
+ + + +# File app/controllers/trips_controller.rb, line 81 +def destroy + @trip = current_user.trips.find(params[:id]) + @trip.destroy + + respond_to do |format| + format.html { redirect_to trips_url } + format.json { head :no_content } + end +end+
GET /trips/1/edit
+ + + +# File app/controllers/trips_controller.rb, line 43 +def edit + @trip = current_user.trips.find(params[:id]) +end+
GET /trips GET /trips.json
+ + + +# File app/controllers/trips_controller.rb, line 10 +def index + @trips = Trip.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @trips } + end +end+
GET /trips/new GET /trips/new.json
+ + + +# File app/controllers/trips_controller.rb, line 33 +def new + @trip = current_user.trips.build + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @trip } + end +end+
GET /trips/1 GET /trips/1.json
+ + + +# File app/controllers/trips_controller.rb, line 21 +def show + @trip = Trip.find(params[:id]) + @visit = @trip.visits.build + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @trip } + end +end+
PUT /trips/1 PUT /trips/1.json
+ + + +# File app/controllers/trips_controller.rb, line 65 +def update + @trip = current_user.trips.find(params[:id]) + + respond_to do |format| + if @trip.update_attributes(params[:trip]) + format.html { redirect_to @trip, notice: 'Trip was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @trip.errors, status: :unprocessable_entity } + end + end +end+
No se usa
+ +Controlador de los tipos
+ +POST /types POST /types.json
+ + + +# File app/controllers/types_controller.rb, line 60 +def create + @type = Type.new(params[:type]) + + respond_to do |format| + if @type.save + format.html { redirect_to @type, notice: 'Type was successfully created.' } + format.json { render json: @type, status: :created, location: @type } + else + format.html { render action: "new" } + format.json { render json: @type.errors, status: :unprocessable_entity } + end + end +end+
DELETE /types/1 DELETE /types/1.json
+ + + +# File app/controllers/types_controller.rb, line 92 +def destroy + @type = Type.find(params[:id]) + @type.destroy + + respond_to do |format| + format.html { redirect_to types_url } + format.json { head :no_content } + end +end+
GET /types/1/edit
+ + + +# File app/controllers/types_controller.rb, line 54 +def edit + @type = Type.find(params[:id]) +end+
GET /types GET /types.json
+ + + +# File app/controllers/types_controller.rb, line 20 +def index + @types = Type.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @types } + end +end+
GET /types/new GET /types/new.json
+ + + +# File app/controllers/types_controller.rb, line 44 +def new + @type = Type.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @type } + end +end+
GET /types GET /types.json Devuelve una lista ordenada por nombre
+ + + +# File app/controllers/types_controller.rb, line 7 +def ordered_index + @types = Type.find(:all, :order => :name) + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @types } + end +end+
GET /types/1 GET /types/1.json
+ + + +# File app/controllers/types_controller.rb, line 33 +def show + @type = Type.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @type } + end +end+
PUT /types/1 PUT /types/1.json
+ + + +# File app/controllers/types_controller.rb, line 76 +def update + @type = Type.find(params[:id]) + + respond_to do |format| + if @type.update_attributes(params[:type]) + format.html { redirect_to @type, notice: 'Type was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @type.errors, status: :unprocessable_entity } + end + end +end+
ActiveRecord::Base + +
ActiveRecord::Base + +
VisitsController para las visitas
+ +POST /visits POST /visits.json
+ + + +# File app/controllers/visits_controller.rb, line 46 +def create + @visit = Visit.new(params[:visit]) + + respond_to do |format| + if @visit.save + format.html { redirect_to @visit.trip, notice: 'Visit was successfully created.' } + format.js + format.json { render json: @visit, status: :created, location: @visit } + else + format.html { render action: "new" } + format.json { render json: @visit.errors, status: :unprocessable_entity } + end + end +end+
DELETE /visits/1 DELETE /visits/1.json
+ + + +# File app/controllers/visits_controller.rb, line 79 +def destroy + @visit = Visit.find(params[:id]) + @visit.destroy + + respond_to do |format| + format.html { redirect_to @visit.trip } + format.json { head :no_content } + end +end+
GET /visits/1/edit
+ + + +# File app/controllers/visits_controller.rb, line 40 +def edit + @visit = Visit.find(params[:id]) +end+
GET /visits GET /visits.json Nos devuelve todas las visitas
+ + + +# File app/controllers/visits_controller.rb, line 6 +def index + @visits = Visit.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @visits } + end +end+
GET /visits/new GET /visits/new.json Para crear una nueva visita
+ + + +# File app/controllers/visits_controller.rb, line 30 +def new + @visit = Visit.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @visit } + end +end+
GET /visits/1 GET /visits/1.json Sólo aquella que coincide con el parámetro +id
+ + + +# File app/controllers/visits_controller.rb, line 18 +def show + @visit = Visit.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @visit } + end +end+
PUT /visits/1 PUT /visits/1.json
+ + + +# File app/controllers/visits_controller.rb, line 63 +def update + @visit = Visit.find(params[:id]) + + respond_to do |format| + if @visit.update_attributes(params[:visit]) + format.html { redirect_to @visit.trip, notice: 'Visit was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @visit.errors, status: :unprocessable_entity } + end + end +end+
No se usa
+ +Use this README file to introduce your application and point to useful +places in the API for learning more. Run “rake doc:app” to generate API +documentation for your models, controllers, helpers, and libraries.
+ +This is the API documentation for Rails Application Documentation.
+
+
+
+
diff --git a/app/views/planet/doc/app/js/darkfish.js b/app/views/planet/doc/app/js/darkfish.js
new file mode 100644
index 0000000..4be722f
--- /dev/null
+++ b/app/views/planet/doc/app/js/darkfish.js
@@ -0,0 +1,153 @@
+/**
+ *
+ * Darkfish Page Functions
+ * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
+ *
+ * Author: Michael Granger También podemos generar un enlace al recurso (página) Home con el siguiente hiperenlace: <%= link_to('Home', planet_index_path) %> Rails ejecuta el código Ruby y lo inserta en la página HTML antes de generar la página. También podemos generar un enlace al recurso (página) Home con el siguiente hiperenlace: <%= link_to('Home', planet_index_path) %> Rails ejecuta el código Ruby y lo inserta en la página HTML antes de generar la página. This site gathers information
of touristic sites from all over
the world and should help you to
organize your trips and your holidays.
Feel free to use it for your
convenience and pleasure. This site gathers information
of touristic sites from all over
the world and should help you to
organize your trips and your holidays.
Feel free to use it for your
convenience and pleasure.
+ Finding your location: checking... Finding your location: checking...
+ Location <%=sanitize @site.description %> Autor:
+ <%= @site.user.name if @site.user %>
+
+ Location <%=sanitize @site.description %> Autor:
+ <%= @site.user.name if @site.user %>
+
+
Name:
<%= @trip.name %>
Date:
<%= @trip.date %>
Autor:
<%= @trip.user.name if @trip.user %>
Description:
<%= simple_format @trip.description %>
Location
Name:
<%= @trip.name %>
Date:
<%= @trip.date %>
Autor:
<%= @trip.user.name if @trip.user %>
Description:
<%= simple_format @trip.description %>
Location <%= notice %> <%= notice %>
+ Última modificación:
+ <%= @type.updated_at %>
+
Name:
@@ -13,3 +18,4 @@
<%= link_to 'Edit', edit_type_path(@type) %> |
<%= link_to 'Back', types_path %>
+
diff --git a/app/views/visits/_form.html.erb b/app/views/visits/_form.html.erb
new file mode 100644
index 0000000..12ab912
--- /dev/null
+++ b/app/views/visits/_form.html.erb
@@ -0,0 +1,29 @@
+<%= form_for(@visit) do |f| %>
+ <% if @visit.errors.any? %>
+ <%= notice %>
+ Trip:
+ <%= @visit.trip_id %>
+
+ Site:
+ <%= @visit.site_id %>
+
+ Hour:
+ <%= @visit.hour %>
+ ActionController::Base
+
+ Helpers que estarán disponibles desde todas las vistas Añade un marcador en un mapa de google Nos permite obtener en formato string el nombre de la ciudad o región
+pasándo como parámetro latitud y longitud Nos permite incluir un javascript. ComentsController nos permite
+controlar las acciones relacionadas con los comentarios POST /coments POST /coments.json DELETE /coments/1 DELETE /coments/1.json GET /coments/1/edit GET /coments GET /coments.json Nos permite crear un nuevo comentario GET /coments/new GET
+/coments/new.json Muestra un comentario especifico GET /coments/1 GET /coments/1.json PUT /coments/1 PUT /coments/1.json No se usa PlanetController ilustra el uso de
+RDoc. La documentación de un proyecto en genera en el
+directorio proy/doc en formato Web con Tal y como muestra el subitulo anterior, este se define empezando la línea
+con ==. En los títulos debe empezar por =. Un [ … ] seguido de texto define una lista titulada, como aquí Se documentan con comentarios justo encima de sus definición, como aquí. Un * o - definen las entradas de una lista itemizada Un URL se define así email o así Pepe Rubio Un número o letra seguido de punto genera una lista númerada + permite generar negrita, igual que con
+HTML _ permite generar cursiva, igual que con HTML permite generar letra de Método que define una acción vacía del controlador Método que define una acción vacía del controlador Método que define una acción vacía del controlador Método para definir la acción que nos permite parsear json de la API de
+googlemaps +No renderiza el layout+ GET /sites /search No se usa ActiveRecord::Base
+
+ SitesController nos permite controlar
+las acciones relacionadas con los sitios POST /sites POST /sites.json DELETE /sites/1 DELETE /sites/1.json GET /sites/1/edit GET /sites GET /sites.json GET /sites/new GET /sites/new.json GET /sites/1 GET /sites/1.json PUT /sites/1 PUT /sites/1.json ActiveRecord::Base
+
+ TripsController nos permite controlar
+las acciones relacionadas con los viajes POST /trips POST /trips.json DELETE /trips/1 DELETE /trips/1.json GET /trips/1/edit GET /trips GET /trips.json GET /trips/new GET /trips/new.json GET /trips/1 GET /trips/1.json PUT /trips/1 PUT /trips/1.json No se usa ActiveRecord::Base
+
+ Controlador de los tipos POST /types POST /types.json DELETE /types/1 DELETE /types/1.json GET /types/1/edit GET /types GET /types.json GET /types/new GET /types/new.json GET /types GET /types.json Devuelve una lista ordenada por nombre GET /types/1 GET /types/1.json PUT /types/1 PUT /types/1.json ActiveRecord::Base
+
+ ActiveRecord::Base
+
+ VisitsController para las visitas POST /visits POST /visits.json DELETE /visits/1 DELETE /visits/1.json GET /visits/1/edit GET /visits GET /visits.json Nos devuelve todas las visitas GET /visits/new GET /visits/new.json Para crear una nueva visita GET /visits/1 GET /visits/1.json Sólo aquella que coincide con el parámetro
+id PUT /visits/1 PUT /visits/1.json No se usa Use this README file to introduce your application and point to useful
+places in the API for learning more. Run “rake doc:app” to generate API
+documentation for your models, controllers, helpers, and libraries. This is the API documentation for Rails Application Documentation.
+
+
+
+
diff --git a/doc/app/js/darkfish.js b/doc/app/js/darkfish.js
new file mode 100644
index 0000000..4be722f
--- /dev/null
+++ b/doc/app/js/darkfish.js
@@ -0,0 +1,153 @@
+/**
+ *
+ * Darkfish Page Functions
+ * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
+ *
+ * Author: Michael Granger Table of Contents - Rails Application Documentation
+
+Pages
+
+
+
+Classes/Modules
+
+
+
+
+
+ Methods
+
+
+
+
+
+
+
diff --git a/app/views/planet/ejemplo.html.erb b/app/views/planet/ejemplo.html.erb
index cb05eb9..f6237be 100644
--- a/app/views/planet/ejemplo.html.erb
+++ b/app/views/planet/ejemplo.html.erb
@@ -1,3 +1,3 @@
-ERb: Extended Ruby
El formato ERb o .erb es HTML extendido con anotaciones Ruby, delimitadas por <% o <%= y %> , como en el siguiente ejemplo
+
ERb: Extended Ruby
El formato ERb o .erb es HTML extendido con anotaciones Ruby, delimitadas por <% o <%= y %> , como en el siguiente ejemplo
-
\ No newline at end of file
diff --git a/app/views/planet/index.html.erb b/app/views/planet/index.html.erb
index bbee722..a4a7a15 100644
--- a/app/views/planet/index.html.erb
+++ b/app/views/planet/index.html.erb
@@ -1 +1 @@
-
Wecome to the Planet Travel Site
Wecome to the Planet Travel Site
\ No newline at end of file
diff --git a/app/views/planet/jsonp.html.erb b/app/views/planet/jsonp.html.erb
new file mode 100644
index 0000000..d7e4fa6
--- /dev/null
+++ b/app/views/planet/jsonp.html.erb
@@ -0,0 +1,18 @@
+<%
+
+require 'open-uri'
+require 'json'
+
+address = params[:address]
+address = address.gsub(" ","%20")
+
+
+result = JSON.parse(open("http://maps.googleapis.com/maps/api/geocode/json?address=#{address}&sensor=true").read)
+
+ %>
+
+ <%=
+
+ result['results'][0]['geometry']['location'][params[:coor]]
+
+ %>
diff --git a/app/views/planet/search.html.erb b/app/views/planet/search.html.erb
new file mode 100644
index 0000000..7bb6480
--- /dev/null
+++ b/app/views/planet/search.html.erb
@@ -0,0 +1,77 @@
+Listing Sites
+
+
+ <% @sites.each do |site| %>
+
+
+
+
+ <% end %>
+
+ <%= link_to image_tag(site.image.url, :class => 'list_image'), site %>
+
+
+
+
+
+
+
+
+ <%= link_to 'Show', site %>
+
+ <% if site.user == current_user %>
+ <%= link_to 'Edit', edit_site_path(site) %>
+ <%= link_to 'Destroy', site,
+ :confirm => 'Are you sure?',
+ :method => :delete %>
+ <% end %>
+
+
+<%= link_to 'New site', new_site_path %>
+
+Viajes
+
+
+ <% @trips.each do |trip| %>
+
+
+
+
+ <% end %>
+
+
+
+
+
+
+ <%= link_to 'Show', trip %>
+
+ <% if trip.user == current_user %>
+ <%= link_to 'Edit', edit_trip_path(trip) %>
+ <%= link_to 'Destroy', trip,
+ :confirm => 'Are you sure?',
+ :method => :delete %>
+ <% end %>
+
+
+<%= link_to 'New Trip', new_trip_path %>
\ No newline at end of file
diff --git a/app/views/sites/_form.html.erb b/app/views/sites/_form.html.erb
new file mode 100644
index 0000000..29f01e2
--- /dev/null
+++ b/app/views/sites/_form.html.erb
@@ -0,0 +1,53 @@
+<%= javascript_include_tag 'http://maps.google.com/maps/api/js?sensor=false' %>
+<%= javascript_include_tag 'sites.form.geolocation' %>
+<%= javascript_include_tag 'sites.get.coordenates' %>
+
+
+<%= form_for(@site) do |f| %>
+ <% if @site.errors.any? %>
+ <%= pluralize(@site.errors.count, "error") %> prohibited this site from being saved:
+
+
+ <% @site.errors.full_messages.each do |msg| %>
+
+
+ <%= f.text_field :name %>
+
+ <%= f.text_area :description , :rows => 4 %>
+
+ <%= f.collection_select(:type_id, Type.find(:all, :order => :name), :id, :name) %>
+
+ <%= f.file_field :image %>
+
+ <%= f.text_field :latitude %>
+
+ <%= f.text_field :longitude %>
+
+ <%= f.text_field :zoom %>
+ <%= pluralize(@site.errors.count, "error") %> prohibited this site from being saved:
+
+
+ <% @site.errors.full_messages.each do |msg| %>
+
+
+ <%= f.text_field :name %>
+
+ <%= f.text_area :description , :rows => 4 %>
+
+ <%= f.collection_select(:type_id, Type.find(:all, :order => :name), :id, :name) %>
+
+ <%= f.text_field :image_url %>
+
+ <%= f.text_field :latitude %>
+
+ <%= f.text_field :longitude %>
+
+ <%= f.text_field :zoom %>
+ Editing site
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @site %> |
+<%= link_to 'Back', sites_path %>
diff --git a/app/views/sites/index.html.erb b/app/views/sites/index.html.erb
new file mode 100644
index 0000000..7a4d6e3
--- /dev/null
+++ b/app/views/sites/index.html.erb
@@ -0,0 +1,46 @@
+Listing Sites
+
+
+ <% @sites.each do |site| %>
+
+
+
+
+ <% end %>
+
+ <%= link_to image_tag(site.image.url, :class => 'list_image'), site %>
+
+
+
+
+
+
+
+
+ <%= link_to 'Show', site %>
+
+ <% if site.user == current_user %>
+ <%= link_to 'Edit', edit_site_path(site) %>
+ <%= link_to 'Destroy', site,
+ :confirm => 'Are you sure?',
+ :method => :delete %>
+ <% end %>
+
+
+<%= link_to 'New site', new_site_path %>
\ No newline at end of file
diff --git a/app/views/sites/new.html.erb b/app/views/sites/new.html.erb
new file mode 100644
index 0000000..2988bdc
--- /dev/null
+++ b/app/views/sites/new.html.erb
@@ -0,0 +1,5 @@
+New site
+
+<%= render 'form' %>
+
+<%= link_to 'Back', sites_path %>
diff --git a/app/views/sites/show.html.erb b/app/views/sites/show.html.erb
new file mode 100644
index 0000000..bd4f618
--- /dev/null
+++ b/app/views/sites/show.html.erb
@@ -0,0 +1,95 @@
+<%= javascript_include_tag 'http://maps.google.com/maps/api/js?sensor=false' %>
+<%= javascript_include_tag 'sites.show.geolocation' %>
+<%= javascript_include_tag 'sites.coments.show.geolocation' %>
+
+
+<%= @site.type.name if @site.type %>
+
+ <%= image_tag(@site.image.url, :class => 'site_image') %>
+
+ <%= @site.name %>
+
+ Comentarios:
+ <% @site.coments.each do |coment| %>
+
+ (<%= get_address(coment.latitude,coment.longitude) if !coment.longitude.nil? %>)
+
+
+
+ <% end %>
+
+
+
+ <%= form_for([@site, @site.coments.build]) do |f| %>
+
+
+ <%= f.text_field :coment %>
+ <%= @site.type.name if @site.type %>
+
+ <%= image_tag(@site.image.url, :class => 'site_image') %>
+
+ <%= @site.name %>
+
+ Comentarios:
+ <% @site.coments.each do |coment| %>
+
+ (<%= get_address(coment.latitude,coment.longitude) if !coment.longitude.nil? %>)
+
+
+
+ <% end %>
+
+
+
+ <%= form_for([@site, @site.coments.build]) do |f| %>
+
+
+ <%= f.text_field :coment %>
+ <%= pluralize(@trip.errors.count, "error") %> prohibited this trip from being saved:
+
+
+ <% @trip.errors.full_messages.each do |msg| %>
+
+
+ <%= f.text_field :name %>
+
+ <%= f.text_area :description %>
+
+ <%= f.date_select :date %>
+
+ <% trip.visits.order(:hour).each do |visit| %>
+
+
+
+
+ <%= add_gmap_marker(visit.site.latitude,visit.site.longitude,visit.site.name) %>
+ <% end %>
+
+ <%= link_to image_tag(visit.site.image.url, :class => 'list_image'), visit.site %>
+
+
+
+
+
+
+
+
+ <%= link_to 'Show', visit.site %>
+
+ <%= link_to 'Destroy', visit,
+ :confirm => 'Are you sure?',
+ :method => :delete if trip.user == current_user %>
+
+
+ <% trip.visits.order(:hour).each do |visit| %>
+
+
+
+
+ <%= add_gmap_marker(visit.site.latitude,visit.site.longitude,visit.site.name) %>
+ <% end %>
+
+ <%= link_to image_tag(visit.site.image_url, :class => 'list_image'), visit.site %>
+
+
+
+
+
+
+
+
+ <%= link_to 'Show', visit.site %>
+
+ <%= link_to 'Destroy', visit,
+ :confirm => 'Are you sure?',
+ :method => :delete if trip.user == current_user %>
+
+ Editing trip
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @trip %> |
+<%= link_to 'Back', trips_path %>
diff --git a/app/views/trips/index.html.erb b/app/views/trips/index.html.erb
new file mode 100644
index 0000000..ec66e06
--- /dev/null
+++ b/app/views/trips/index.html.erb
@@ -0,0 +1 @@
+
Viajes
<% @trips.each do |trip| %>
<% end %>
<%= link_to 'Show', trip %>
<% if trip.user == current_user %>
<%= link_to 'Edit', edit_trip_path(trip) %>
<%= link_to 'Destroy', trip,
:confirm => 'Are you sure?',
:method => :delete %>
<% end %>
<%= link_to 'New Trip', new_trip_path %>
\ No newline at end of file
diff --git a/app/views/trips/new.html.erb b/app/views/trips/new.html.erb
new file mode 100644
index 0000000..dd3e49d
--- /dev/null
+++ b/app/views/trips/new.html.erb
@@ -0,0 +1,5 @@
+New trip
+
+<%= render 'form' %>
+
+<%= link_to 'Back', trips_path %>
diff --git a/app/views/trips/show.html.erb b/app/views/trips/show.html.erb
new file mode 100644
index 0000000..926ad00
--- /dev/null
+++ b/app/views/trips/show.html.erb
@@ -0,0 +1 @@
+<%= javascript_include_tag 'http://maps.google.com/maps/api/js?sensor=false' %>
Sitios a visitar
<%= render(@trip) %>
<% if @trip.user == current_user %>
<%= form_for(@visit, :remote => true) do |f| %>
<%= f.number_field :trip_id, :value => @trip.id, :hidden => true %>
<%= f.collection_select(:site_id,
Site.all,
:id,
:name) %>
<%= f.select(:hour, Array.new(24, 0).fill {|i| [(i.to_s + 'H'), i]}) %>
<%= f.submit "Añadir sitio" %>
<% end %>
<% end %>
<% if @trip.user == current_user %>
<%= link_to 'Edit', edit_trip_path(@trip) %> |
<% end %>
<%= link_to 'Back', trips_path %>
\ No newline at end of file
diff --git a/app/views/trips/show.html.erb~ b/app/views/trips/show.html.erb~
new file mode 100644
index 0000000..949b357
--- /dev/null
+++ b/app/views/trips/show.html.erb~
@@ -0,0 +1 @@
+<%= javascript_include_tag 'http://maps.google.com/maps/api/js?sensor=false' %>
Sitios a visitar
<%= render(@trip) %>
<% if @trip.user == current_user %>
<%= form_for(@visit, :remote => true) do |f| %>
<%= f.number_field :trip_id, :value => @trip.id, :hidden => true %>
<%= f.collection_select(:site_id,
Site.all,
:id,
:name) %>
<%= f.select(:hour, Array.new(24, 0).fill {|i| [(i.to_s + 'H'), i]}) %>
<%= f.submit "Añadir sitio" %>
<% end %>
<% end %>
<% if @trip.user == current_user %>
<%= link_to 'Edit', edit_trip_path(@trip) %> |
<% end %>
<%= link_to 'Back', trips_path %>
\ No newline at end of file
diff --git a/app/views/types/index.html.erb b/app/views/types/index.html.erb
index 50bda49..7fef715 100644
--- a/app/views/types/index.html.erb
+++ b/app/views/types/index.html.erb
@@ -1,24 +1,29 @@
-Listing types
-
-
-
+
-
-
-<% @types.each do |type| %>
- Name
- Description
-
-
-
-
-
-<% end %>
-<%= type.name %>
- <%= type.description %>
- <%= link_to 'Show', type %>
- <%= link_to 'Edit', edit_type_path(type) %>
- <%= link_to 'Destroy', type, confirm: 'Are you sure?', method: :delete %>
- Listing Types
+
+
+ <% @types.each do |type| %>
+
+
+
+
+ <% end %>
+
+
+
+
+
+
+ <%= link_to 'Show', type %>
+
+ <%= link_to 'Edit', edit_type_path(type) %>
+ <%= link_to 'Destroy', type,
+ :confirm => 'Are you sure?',
+ :method => :delete %>
+
diff --git a/app/views/types/ordered_index.html.erb b/app/views/types/ordered_index.html.erb
new file mode 100644
index 0000000..0eabc9e
--- /dev/null
+++ b/app/views/types/ordered_index.html.erb
@@ -0,0 +1,28 @@
+Listing ordered types
+
+
+
+
+
+
+
+<% @types.each do |type| %>
+ Última modificación
+ Name
+ Description
+
+
+
+
+
+<% end %>
+<%= type.updated_at %>
+ <%= type.name %>
+ <%= type.description %>
+ <%= link_to 'Show', type %>
+ <%= link_to 'Edit', edit_type_path(type) %>
+ <%= link_to 'Destroy', type, confirm: 'Are you sure?', method: :delete %>
+
+
+<%= link_to 'New Type', new_type_path %>
+
diff --git a/app/views/types/show.html.erb b/app/views/types/show.html.erb
index 98b32e7..eeef754 100644
--- a/app/views/types/show.html.erb
+++ b/app/views/types/show.html.erb
@@ -1,4 +1,9 @@
-<%= pluralize(@visit.errors.count, "error") %> prohibited this visit from being saved:
+
+
+ <% @visit.errors.full_messages.each do |msg| %>
+
+
+ <%= f.number_field :trip_id %>
+
+ <%= f.number_field :site_id %>
+
+ <%= f.number_field :hour %>
+ Editing visit
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @visit %> |
+<%= link_to 'Back', visits_path %>
diff --git a/app/views/visits/index.html.erb b/app/views/visits/index.html.erb
new file mode 100644
index 0000000..c7bea46
--- /dev/null
+++ b/app/views/visits/index.html.erb
@@ -0,0 +1,27 @@
+Listing visits
+
+
+
+
+
+
+
+<% @visits.each do |visit| %>
+ Trip
+ Site
+ Hour
+
+
+
+
+
+<% end %>
+<%= visit.trip_id %>
+ <%= visit.site_id %>
+ <%= visit.hour %>
+ <%= link_to 'Show', visit %>
+ <%= link_to 'Edit', edit_visit_path(visit) %>
+ <%= link_to 'Destroy', visit, confirm: 'Are you sure?', method: :delete %>
+
+
+<%= link_to 'New Visit', new_visit_path %>
diff --git a/app/views/visits/new.html.erb b/app/views/visits/new.html.erb
new file mode 100644
index 0000000..1be1930
--- /dev/null
+++ b/app/views/visits/new.html.erb
@@ -0,0 +1,5 @@
+New visit
+
+<%= render 'form' %>
+
+<%= link_to 'Back', visits_path %>
diff --git a/app/views/visits/show.html.erb b/app/views/visits/show.html.erb
new file mode 100644
index 0000000..2bf41f5
--- /dev/null
+++ b/app/views/visits/show.html.erb
@@ -0,0 +1,20 @@
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Parent
+
+ Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Methods
+
+
+
+
+Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+module ApplicationHelper
+
+ Public Instance Methods
+
+
+ IMPORTANTE: Ha de existir previamente un mapa en pantalla llamado 'map'
+
+
+
+ # File app/helpers/application_helper.rb, line 32
+def add_gmap_marker (latitude,longitude,text)
+ javascript = ""
+ if(!latitude.nil?)
+ javascript = "<script>
+ latlng = new google.maps.LatLng(#{latitude}, #{longitude});
+ marker = new google.maps.Marker({
+ position: latlng,
+ map: map,
+ title:'#{text}'
+ });
+ </script>"
+ end
+ raw(javascript)
+end
+ # File app/helpers/application_helper.rb, line 14
+def get_address(latitude,longitude)
+
+ if (!latitude.nil?)
+ require 'open-uri'
+ require 'json'
+ result = JSON.parse(open("http://maps.googleapis.com/maps/api/geocode/json?latlng=#{latitude},#{longitude}&sensor=false").read)
+ localidad = "near "+result['results'][0]['address_components'][3]['long_name']
+ else
+ localidad = ""
+ end
+
+ localidad
+end
+ Deprecated: Usar javascript_include_tag en su lugar
+
+
+
+ # File app/helpers/application_helper.rb, line 6
+def include_javascript (file)
+ s = " <script type=\"text/javascript\">" + render(:file => file) + "</script>"
+ content_for(:head, raw(s))
+end
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Parent
+
+ Methods
+
+
+Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+class ComentsController
+
+ ¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show
+
+ Public Instance Methods
+
+
+ # File app/controllers/coments_controller.rb, line 62
+def create
+ @coment = current_user.coments.build(params[:coment]) # Asigna solo si comentario asociado a current_user
+
+ if !params[:site_id].nil?
+ @site = Site.find(params[:site_id])
+ else
+ @site = Site.find(params[:coment][:site_id])
+ end
+ @coment = @site.coments.create(params[:coment])
+
+
+
+ respond_to do |format|
+ if @coment.save
+ format.html { redirect_to site_path(@site), notice: 'Coment was successfully created.' }
+ format.json { render json: site_path(@site), status: :created, location: @coment }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @coment.errors, status: :unprocessable_entity }
+ end
+ end
+end
+ # File app/controllers/coments_controller.rb, line 104
+def destroy
+ @coment = current_user.coments.find(params[:id]) # busca solo en sitios asociados a current_user
+# @coment = Coment.find(params[:id])
+ @coment.destroy
+
+ respond_to do |format|
+ format.html { redirect_to coments_url }
+ format.json { head :no_content }
+ end
+end
+ # File app/controllers/coments_controller.rb, line 56
+def edit
+ @coment = Coment.find(params[:id])
+end
+ # File app/controllers/coments_controller.rb, line 10
+def index
+
+
+ if params[:site_id].nil? #Para que en el enlace de comentarios solo aparezcan los de el sitio en cuestión
+ @coments = Coment.all #si no, se pondría solo esta linea
+ else
+ @coments = Site.find(params[:site_id]).coments
+ end
+
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @coments }
+ end
+end
+ # File app/controllers/coments_controller.rb, line 41
+def new
+ @coment = Coment.new
+ #@site = Site.find(params[:site_id])
+ if !params[:site_id].nil?
+ @site = Site.find(params[:site_id])
+ end
+
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @coment }
+ end
+end
+ # File app/controllers/coments_controller.rb, line 29
+def show
+ @coment = Coment.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @coment }
+ end
+end
+ # File app/controllers/coments_controller.rb, line 87
+def update
+ @coment = current_user.coments.find(params[:id]) # busca solo en sitios asociados a current_user
+ # @coment = Coment.find(params[:id])
+
+ respond_to do |format|
+ if @coment.update_attributes(params[:coment])
+ format.html { redirect_to @coment, notice: 'Coment was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @coment.errors, status: :unprocessable_entity }
+ end
+ end
+end
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+module ComentsHelper
+
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Parent
+
+ Methods
+
+
+Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+class PlanetController
+
+ $proy> rake doc:app
+
+Algunos comandos de formateo
+
+
+
+
+
+
+
+
+teletipo, igual que con
+HTMLPublic Instance Methods
+
+
+
+
+
+ # File app/controllers/planet_controller.rb, line 34
+def contact
+end
+ # File app/controllers/planet_controller.rb, line 40
+def ejemplo
+end
+ # File app/controllers/planet_controller.rb, line 31
+def index
+end
+ # File app/controllers/planet_controller.rb, line 45
+ def jsonp
+ render :layout => false
+end
+ # File app/controllers/planet_controller.rb, line 25
+def search
+ @sites = Site.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%")
+ @trips = Trip.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%")
+end
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+module PlanetHelper
+
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Parent
+
+ Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+class Site
+
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Parent
+
+ Methods
+
+
+Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+class SitesController
+
+ ¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show
+
+ Public Instance Methods
+
+
+ # File app/controllers/sites_controller.rb, line 56
+def create
+ @site = current_user.sites.build(params[:site]) # Asigna solo si sitio asociado a current_user
+
+ respond_to do |format|
+ if @site.save
+ format.html { redirect_to @site, notice: 'Site was successfully created.' }
+ format.json { render json: @site, status: :created, location: @site }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @site.errors, status: :unprocessable_entity }
+ end
+ end
+end
+ # File app/controllers/sites_controller.rb, line 88
+def destroy
+ @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user
+ @site.destroy
+
+ respond_to do |format|
+ format.html { redirect_to sites_url }
+ format.json { head :no_content }
+ end
+end
+ # File app/controllers/sites_controller.rb, line 50
+def edit
+ @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user
+end
+ # File app/controllers/sites_controller.rb, line 12
+def index
+ if params[:type_id].nil? or params[:type_id].empty?
+ @sites = Site.all # path: /types
+ else
+ @sites = Type.find(params[:type_id]).sites # path: /types/id/sites
+ end
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @sites }
+ end
+end
+ # File app/controllers/sites_controller.rb, line 40
+def new
+ @site = current_user.sites.build # crea sitio vacio asociado a current_user
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @site }
+ end
+end
+ # File app/controllers/sites_controller.rb, line 26
+def show
+ @site = Site.find(params[:id])
+
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @site }
+ format.json { render json: @coments }
+
+ end
+end
+ # File app/controllers/sites_controller.rb, line 72
+def update
+ @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user
+
+ respond_to do |format|
+ if @site.update_attributes(params[:site])
+ format.html { redirect_to @site, notice: 'Site was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @site.errors, status: :unprocessable_entity }
+ end
+ end
+end
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Methods
+
+
+
+
+Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+module SitesHelper
+
+ Public Instance Methods
+
+
+ # File app/helpers/sites_helper.rb, line 2
+def new_gmap(latitude,longitude,zoom)
+
+end
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Parent
+
+ Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+class Trip
+
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Parent
+
+ Methods
+
+
+Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+class TripsController
+
+ ¡IMPORTANTE! Necesario haber iniciado sesión con un usuario, excepto para el index y para show
+
+ Public Instance Methods
+
+
+ # File app/controllers/trips_controller.rb, line 49
+def create
+ @trip = current_user.trips.build(params[:trip])
+
+ respond_to do |format|
+ if @trip.save
+ format.html { redirect_to @trip, notice: 'Trip was successfully created.' }
+ format.json { render json: @trip, status: :created, location: @trip }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @trip.errors, status: :unprocessable_entity }
+ end
+ end
+end
+ # File app/controllers/trips_controller.rb, line 81
+def destroy
+ @trip = current_user.trips.find(params[:id])
+ @trip.destroy
+
+ respond_to do |format|
+ format.html { redirect_to trips_url }
+ format.json { head :no_content }
+ end
+end
+ # File app/controllers/trips_controller.rb, line 43
+def edit
+ @trip = current_user.trips.find(params[:id])
+end
+ # File app/controllers/trips_controller.rb, line 10
+def index
+ @trips = Trip.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @trips }
+ end
+end
+ # File app/controllers/trips_controller.rb, line 33
+def new
+ @trip = current_user.trips.build
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @trip }
+ end
+end
+ # File app/controllers/trips_controller.rb, line 21
+def show
+ @trip = Trip.find(params[:id])
+ @visit = @trip.visits.build
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @trip }
+ end
+end
+ # File app/controllers/trips_controller.rb, line 65
+def update
+ @trip = current_user.trips.find(params[:id])
+
+ respond_to do |format|
+ if @trip.update_attributes(params[:trip])
+ format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @trip.errors, status: :unprocessable_entity }
+ end
+ end
+end
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+module TripsHelper
+
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Parent
+
+ Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+class Type
+
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Parent
+
+ Methods
+
+
+Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+class TypesController
+
+ Public Instance Methods
+
+
+ # File app/controllers/types_controller.rb, line 60
+def create
+ @type = Type.new(params[:type])
+
+ respond_to do |format|
+ if @type.save
+ format.html { redirect_to @type, notice: 'Type was successfully created.' }
+ format.json { render json: @type, status: :created, location: @type }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @type.errors, status: :unprocessable_entity }
+ end
+ end
+end
+ # File app/controllers/types_controller.rb, line 92
+def destroy
+ @type = Type.find(params[:id])
+ @type.destroy
+
+ respond_to do |format|
+ format.html { redirect_to types_url }
+ format.json { head :no_content }
+ end
+end
+ # File app/controllers/types_controller.rb, line 54
+def edit
+ @type = Type.find(params[:id])
+end
+ # File app/controllers/types_controller.rb, line 20
+def index
+ @types = Type.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @types }
+ end
+end
+ # File app/controllers/types_controller.rb, line 44
+def new
+ @type = Type.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @type }
+ end
+end
+ # File app/controllers/types_controller.rb, line 7
+def ordered_index
+ @types = Type.find(:all, :order => :name)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @types }
+ end
+end
+ # File app/controllers/types_controller.rb, line 33
+def show
+ @type = Type.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @type }
+ end
+end
+ # File app/controllers/types_controller.rb, line 76
+def update
+ @type = Type.find(params[:id])
+
+ respond_to do |format|
+ if @type.update_attributes(params[:type])
+ format.html { redirect_to @type, notice: 'Type was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @type.errors, status: :unprocessable_entity }
+ end
+ end
+end
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+module TypesHelper
+
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Parent
+
+ Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+class User
+
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Parent
+
+ Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+class Visit
+
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Parent
+
+ Methods
+
+
+Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+class VisitsController
+
+ Public Instance Methods
+
+
+ # File app/controllers/visits_controller.rb, line 46
+def create
+ @visit = Visit.new(params[:visit])
+
+ respond_to do |format|
+ if @visit.save
+ format.html { redirect_to @visit.trip, notice: 'Visit was successfully created.' }
+ format.js
+ format.json { render json: @visit, status: :created, location: @visit }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @visit.errors, status: :unprocessable_entity }
+ end
+ end
+end
+ # File app/controllers/visits_controller.rb, line 79
+def destroy
+ @visit = Visit.find(params[:id])
+ @visit.destroy
+
+ respond_to do |format|
+ format.html { redirect_to @visit.trip }
+ format.json { head :no_content }
+ end
+end
+ # File app/controllers/visits_controller.rb, line 40
+def edit
+ @visit = Visit.find(params[:id])
+end
+ # File app/controllers/visits_controller.rb, line 6
+def index
+ @visits = Visit.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @visits }
+ end
+end
+ # File app/controllers/visits_controller.rb, line 30
+def new
+ @visit = Visit.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @visit }
+ end
+end
+ # File app/controllers/visits_controller.rb, line 18
+def show
+ @visit = Visit.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @visit }
+ end
+end
+ # File app/controllers/visits_controller.rb, line 63
+def update
+ @visit = Visit.find(params[:id])
+
+ respond_to do |format|
+ if @visit.update_attributes(params[:visit])
+ format.html { redirect_to @visit.trip, notice: 'Visit was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @visit.errors, status: :unprocessable_entity }
+ end
+ end
+end
+
+ Home
+ Classes
+ Methods
+
+
+
Defined In
+
+
+Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+module VisitsHelper
+
+
+ Home
+ Classes
+ Methods
+
+
+
Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+
+ Home
+ Classes
+ Methods
+
+
+
Pages
+
+
+
+
+Class and Module Index
+
+
+
+
+Table of Contents - Rails Application Documentation
+
+Pages
+
+
+
+Classes/Modules
+
+
+
+
+
+ Methods
+
+
+
+
+
+
+
diff --git a/public/system/images/10/original/reichstag.png b/public/system/images/10/original/reichstag.png
new file mode 100644
index 0000000..8b95380
Binary files /dev/null and b/public/system/images/10/original/reichstag.png differ
diff --git a/public/system/images/11/original/pergamo.png b/public/system/images/11/original/pergamo.png
new file mode 100644
index 0000000..7e462c2
Binary files /dev/null and b/public/system/images/11/original/pergamo.png differ
diff --git a/public/system/images/12/original/ETSIT2.gif b/public/system/images/12/original/ETSIT2.gif
new file mode 100644
index 0000000..a0c7809
Binary files /dev/null and b/public/system/images/12/original/ETSIT2.gif differ
diff --git a/public/system/images/13/original/eiffel.jpg b/public/system/images/13/original/eiffel.jpg
new file mode 100644
index 0000000..9df1b87
Binary files /dev/null and b/public/system/images/13/original/eiffel.jpg differ
diff --git a/public/system/images/7/original/pedriza.png b/public/system/images/7/original/pedriza.png
new file mode 100644
index 0000000..8d300fb
Binary files /dev/null and b/public/system/images/7/original/pedriza.png differ
diff --git a/public/system/images/8/original/florencia.png b/public/system/images/8/original/florencia.png
new file mode 100644
index 0000000..6398a2e
Binary files /dev/null and b/public/system/images/8/original/florencia.png differ
diff --git a/public/system/images/9/original/arbol1.png b/public/system/images/9/original/arbol1.png
new file mode 100644
index 0000000..6affc09
Binary files /dev/null and b/public/system/images/9/original/arbol1.png differ
diff --git a/test/fixtures/coments.yml b/test/fixtures/coments.yml
new file mode 100644
index 0000000..d10e661
--- /dev/null
+++ b/test/fixtures/coments.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ coment: MyString
+ user: one
+ site: one
+
+two:
+ coment: MyString
+ user: two
+ site: two
diff --git a/test/fixtures/coments.yml~ b/test/fixtures/coments.yml~
new file mode 100644
index 0000000..e7e2ac9
--- /dev/null
+++ b/test/fixtures/coments.yml~
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ coment: MyString
+ user_id: 1
+ site_id: 1
+
+two:
+ coment: MyString
+ user_id: 1
+ site_id: 1
diff --git a/test/fixtures/sites.yml b/test/fixtures/sites.yml
new file mode 100644
index 0000000..5cc96ba
--- /dev/null
+++ b/test/fixtures/sites.yml
@@ -0,0 +1,21 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ name: MyString
+ description: MyText
+ type: one
+ image_url: MyString
+ user: one
+ latitude: 1
+ longitude: 1
+ zoom: 5
+
+two:
+ name: YourString
+ description: YourText
+ type: two
+ image_url: YourString
+ user: two
+ latitude: 1
+ longitude: 1
+ zoom: 5
diff --git a/test/fixtures/sites.yml~ b/test/fixtures/sites.yml~
new file mode 100644
index 0000000..92ffa0c
--- /dev/null
+++ b/test/fixtures/sites.yml~
@@ -0,0 +1,21 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ name: MyString
+ description: MyText
+ type: one
+ image_url: MyString
+ user: one
+ latitud: 1
+ longitud: 1
+ zoom: 5
+
+two:
+ name: YourString
+ description: YourText
+ type: two
+ image_url: YourString
+ user: two
+ latitud: 1
+ longitud: 1
+ zoom: 5
diff --git a/test/fixtures/trips.yml b/test/fixtures/trips.yml
new file mode 100644
index 0000000..2b0ecb6
--- /dev/null
+++ b/test/fixtures/trips.yml
@@ -0,0 +1,13 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ name: MyString
+ description: MyText
+ date: 2012-04-09
+ user: one
+
+two:
+ name: YourString
+ description: YourText
+ date: 2012-04-09
+ user: two
\ No newline at end of file
diff --git a/test/fixtures/types.yml b/test/fixtures/types.yml
index 53b2c6a..79e980b 100644
--- a/test/fixtures/types.yml
+++ b/test/fixtures/types.yml
@@ -1,5 +1,3 @@
-# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
-
one:
name: MyString
description: MyText
@@ -7,3 +5,6 @@ one:
two:
name: MyString
description: MyText
+
+
+# Podriamos aadir nuevos datos de inicializacin, que se referencian como
diff --git a/test/fixtures/types.yml~ b/test/fixtures/types.yml~
new file mode 100644
index 0000000..c6a300d
--- /dev/null
+++ b/test/fixtures/types.yml~
@@ -0,0 +1,12 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ name: MyString
+ description: MyText
+
+two:
+ name: MyString
+ description: MyText
+
+
+# Podriamos aadir nuevos datos de inicializacin, que se referencian como
\ No newline at end of file
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
new file mode 100644
index 0000000..9625621
--- /dev/null
+++ b/test/fixtures/users.yml
@@ -0,0 +1,17 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one:
+ name: Jose Perez
+ email: jose.perez@gmail.com
+ encrypted_password: perez22222
+# column: value
+#
+two:
+ name: Jose Perez
+ email: jose.perez@me.com
+ encrypted_password: perez33333
+# column: value
diff --git a/test/fixtures/users.yml~ b/test/fixtures/users.yml~
new file mode 100644
index 0000000..2e8c5e4
--- /dev/null
+++ b/test/fixtures/users.yml~
@@ -0,0 +1,17 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one:
+ name: Jose Perez
+ email: jose.perez@gmail.com
+ encrypted_password: perez22222
+# column: value
+#
+two:
+ name: Jose Perez
+ email: jose.perez@me.com
+ encrypted_password: perez33333
+# column: value
diff --git a/test/fixtures/visits.yml b/test/fixtures/visits.yml
new file mode 100644
index 0000000..f539c19
--- /dev/null
+++ b/test/fixtures/visits.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ trip: one
+ site: one
+ hour: 9
+
+two:
+ trip: two
+ site: two
+ hour: 9
\ No newline at end of file
diff --git a/test/functional/coments_controller_test.rb b/test/functional/coments_controller_test.rb
new file mode 100644
index 0000000..04c824b
--- /dev/null
+++ b/test/functional/coments_controller_test.rb
@@ -0,0 +1,51 @@
+require 'test_helper'
+
+class ComentsControllerTest < ActionController::TestCase
+ setup do
+ @coment = coments(:one)
+ @user = @coment.user
+ sign_in @user
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:coments)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create coment" do
+ assert_difference('Coment.count') do
+ post :create, coment: @coment.attributes
+ end
+
+ assert_redirected_to site_path(assigns(:site))
+ end
+
+ test "should show coment" do
+ get :show, id: @coment
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @coment
+ assert_response :success
+ end
+
+ test "should update coment" do
+ put :update, id: @coment, coment: @coment.attributes
+ assert_redirected_to coment_path(assigns(:coment))
+ end
+
+ test "should destroy coment" do
+ assert_difference('Coment.count', -1) do
+ delete :destroy, id: @coment
+ end
+
+ assert_redirected_to coments_path
+ end
+end
diff --git a/test/functional/coments_controller_test.rb~ b/test/functional/coments_controller_test.rb~
new file mode 100644
index 0000000..16bf372
--- /dev/null
+++ b/test/functional/coments_controller_test.rb~
@@ -0,0 +1,51 @@
+require 'test_helper'
+
+class ComentsControllerTest < ActionController::TestCase
+ setup do
+ @coment = coments(:one)
+ @user = @coment.user
+ sign_in @user
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:coments)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create coment" do
+ assert_difference('Coment.count') do
+ post :create, coment: @coment.attributes
+ end
+
+ assert_redirected_to site_path(assigns(:coment))
+ end
+
+ test "should show coment" do
+ get :show, id: @coment
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @coment
+ assert_response :success
+ end
+
+ test "should update coment" do
+ put :update, id: @coment, coment: @coment.attributes
+ assert_redirected_to coment_path(assigns(:coment))
+ end
+
+ test "should destroy coment" do
+ assert_difference('Coment.count', -1) do
+ delete :destroy, id: @coment
+ end
+
+ assert_redirected_to coments_path
+ end
+end
diff --git a/test/functional/planet_controller_test.rb b/test/functional/planet_controller_test.rb
index 88229e0..1f1b4fd 100644
--- a/test/functional/planet_controller_test.rb
+++ b/test/functional/planet_controller_test.rb
@@ -1,14 +1,28 @@
-require 'test_helper'
-
-class PlanetControllerTest < ActionController::TestCase
- test "should get index" do
- get :index
- assert_response :success
- end
-
- test "should get contact" do
- get :contact
- assert_response :success
- end
-
-end
+require 'test_helper'
+
+class PlanetControllerTest < ActionController::TestCase
+ test "should get index" do
+ get :index
+ assert_response :success
+ end
+
+ test "should get contact" do
+ get :contact
+ assert_response :success
+ end
+
+ test "should get ejemplo" do
+ get :ejemplo
+ assert_response :success
+ end
+
+ test "should get author" do
+ get :author
+ assert_response :success
+ end
+
+ test "should get search found" do
+ get :search, :search => "hola".to_param
+ assert_response :success
+ end
+end
diff --git a/test/functional/sites_controller_test.rb b/test/functional/sites_controller_test.rb
new file mode 100644
index 0000000..c8f4720
--- /dev/null
+++ b/test/functional/sites_controller_test.rb
@@ -0,0 +1,56 @@
+require 'test_helper'
+
+class SitesControllerTest < ActionController::TestCase
+ setup do
+ @site = sites(:one)
+ @update = { # @update: parametros diferentes
+ :name => 'AnotherType',
+ :description => 'AnotherText',
+ :type_id => types(:one).id
+ }
+ @user = @site.user
+ sign_in @user
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:sites)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create site" do
+ assert_difference('Site.count') do
+ post :create, site: @update
+ end
+
+ assert_redirected_to site_path(assigns(:site))
+ end
+
+ test "should show site" do
+ get :show, id: @site
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @site
+ assert_response :success
+ end
+
+ test "should update site" do
+ put :update, id: @site, site: @update
+ assert_redirected_to site_path(assigns(:site))
+ end
+
+ test "should destroy site" do
+ assert_difference('Site.count', -1) do
+ delete :destroy, id: @site
+ end
+
+ assert_redirected_to sites_path
+ end
+end
diff --git a/test/functional/trips_controller_test.rb b/test/functional/trips_controller_test.rb
new file mode 100644
index 0000000..da22239
--- /dev/null
+++ b/test/functional/trips_controller_test.rb
@@ -0,0 +1,56 @@
+require 'test_helper'
+
+class TripsControllerTest < ActionController::TestCase
+ setup do
+ @trip = trips(:one)
+ @update = { # @update: parametros diferentes
+ :name => 'AnotherType',
+ :description => 'AnotherText',
+ :date => '2012-04-09'
+ }
+ @user = @trip.user
+ sign_in @user
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:trips)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create trip" do
+ assert_difference('Trip.count') do
+ post :create, trip: @update
+ end
+
+ assert_redirected_to trip_path(assigns(:trip))
+ end
+
+ test "should show trip" do
+ get :show, id: @trip
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @trip
+ assert_response :success
+ end
+
+ test "should update trip" do
+ put :update, id: @trip, trip: @update
+ assert_redirected_to trip_path(assigns(:trip))
+ end
+
+ test "should destroy trip" do
+ assert_difference('Trip.count', -1) do
+ delete :destroy, id: @trip
+ end
+
+ assert_redirected_to trips_path
+ end
+end
diff --git a/test/functional/types_controller_test.rb b/test/functional/types_controller_test.rb
index 2e1931b..1da4990 100644
--- a/test/functional/types_controller_test.rb
+++ b/test/functional/types_controller_test.rb
@@ -3,6 +3,12 @@
class TypesControllerTest < ActionController::TestCase
setup do
@type = types(:one)
+ @update = { # @update: parametros diferentes
+ :name => 'AnotherType',
+ :description => 'AnotherText',
+ }
+ @user = users(:one)
+ sign_in @user
end
test "should get index" do
@@ -18,7 +24,7 @@ class TypesControllerTest < ActionController::TestCase
test "should create type" do
assert_difference('Type.count') do
- post :create, type: @type.attributes
+ post :create, type: @update
end
assert_redirected_to type_path(assigns(:type))
@@ -35,7 +41,7 @@ class TypesControllerTest < ActionController::TestCase
end
test "should update type" do
- put :update, id: @type, type: @type.attributes
+ put :update, id: @type, type: @update
assert_redirected_to type_path(assigns(:type))
end
diff --git a/test/functional/visits_controller_test.rb b/test/functional/visits_controller_test.rb
new file mode 100644
index 0000000..f988f15
--- /dev/null
+++ b/test/functional/visits_controller_test.rb
@@ -0,0 +1,50 @@
+require 'test_helper'
+
+class VisitsControllerTest < ActionController::TestCase
+ setup do
+ @visit = visits(:one)
+ @trip = @visit.trip
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:visits)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create visit" do
+ assert_difference('Visit.count') do
+ post :create, visit: @visit.attributes
+ end
+
+ assert_redirected_to @trip
+ end
+
+ test "should show visit" do
+ get :show, id: @visit
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @visit
+ assert_response :success
+ end
+
+ test "should update visit" do
+ put :update, id: @visit, visit: @visit.attributes
+ assert_redirected_to @trip
+ end
+
+ test "should destroy visit" do
+ assert_difference('Visit.count', -1) do
+ delete :destroy, id: @visit
+ end
+
+ assert_redirected_to @trip
+ end
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 8bf1192..2d5a817 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -11,3 +11,7 @@ class ActiveSupport::TestCase
# Add more helper methods to be used by all tests here...
end
+
+ActionController::TestCase.class_eval do
+ include Devise::TestHelpers
+end
\ No newline at end of file
diff --git a/test/unit/coment_test.rb b/test/unit/coment_test.rb
new file mode 100644
index 0000000..da19270
--- /dev/null
+++ b/test/unit/coment_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class ComentTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/unit/helpers/coments_helper_test.rb b/test/unit/helpers/coments_helper_test.rb
new file mode 100644
index 0000000..d2cf3c0
--- /dev/null
+++ b/test/unit/helpers/coments_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class ComentsHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/helpers/sites_helper_test.rb b/test/unit/helpers/sites_helper_test.rb
new file mode 100644
index 0000000..0e92edf
--- /dev/null
+++ b/test/unit/helpers/sites_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class SitesHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/helpers/trips_helper_test.rb b/test/unit/helpers/trips_helper_test.rb
new file mode 100644
index 0000000..dcfddff
--- /dev/null
+++ b/test/unit/helpers/trips_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class TripsHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/helpers/visits_helper_test.rb b/test/unit/helpers/visits_helper_test.rb
new file mode 100644
index 0000000..6f1596c
--- /dev/null
+++ b/test/unit/helpers/visits_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class VisitsHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/site_test.rb b/test/unit/site_test.rb
new file mode 100644
index 0000000..2826c6a
--- /dev/null
+++ b/test/unit/site_test.rb
@@ -0,0 +1,17 @@
+require 'test_helper'
+
+class SiteTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+
+ # site creado sin atributos es invalido y genera errores
+ test "Site attributes must not be empty" do
+ site = Site.new
+ assert site.invalid? # Test pasa si validacin no pasa
+ assert site.errors[:name].any?
+ assert not(site.errors[:description].any?)
+ assert site.errors[:type_id].any?
+ # assert site.errors[:image_url].any? not used with paperclip
+ end
+end
\ No newline at end of file
diff --git a/test/unit/trip_test.rb b/test/unit/trip_test.rb
new file mode 100644
index 0000000..1ed8ca6
--- /dev/null
+++ b/test/unit/trip_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class TripTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/unit/type_test.rb b/test/unit/type_test.rb
index 0ce1172..f777ffb 100644
--- a/test/unit/type_test.rb
+++ b/test/unit/type_test.rb
@@ -4,4 +4,12 @@ class TypeTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
-end
+
+ # type creado sin atributos es invalido y genera errores
+ test "Type attributes must not be empty" do
+ type = Type.new
+ assert type.invalid? # Test pasa si validacin no pasa
+ assert type.errors[:name].any?
+ assert type.errors[:description].any?
+ end
+end
\ No newline at end of file
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
new file mode 100644
index 0000000..82f61e0
--- /dev/null
+++ b/test/unit/user_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class UserTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/unit/visit_test.rb b/test/unit/visit_test.rb
new file mode 100644
index 0000000..a34aa33
--- /dev/null
+++ b/test/unit/visit_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class VisitTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end