diff --git a/.gitignore b/.gitignore index 28a4c21..1842f10 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,7 @@ # ignore al .DS_store files of MAC OSX .DS_Store +# ignore paperclip installation files +public/system +.project + diff --git a/.gitignore~ b/.gitignore~ new file mode 100644 index 0000000..28a4c21 --- /dev/null +++ b/.gitignore~ @@ -0,0 +1,18 @@ +# See http://help.github.com/ignore-files/ for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile ~/.gitignore_global + +# Ignore bundler config +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 + +# Ignore all logfiles and tempfiles. +/log/*.log +/tmp + +# ignore al .DS_store files of MAC OSX +.DS_Store diff --git a/Gemfile b/Gemfile index 7764763..6d784e8 100644 --- a/Gemfile +++ b/Gemfile @@ -1,38 +1,51 @@ -source 'https://rubygems.org' - -gem 'rails', '3.2.2' - -# Bundle edge Rails instead: -# gem 'rails', :git => 'git://github.com/rails/rails.git' - -gem 'sqlite3' - - -# Gems used only for assets and not required -# in production environments by default. -group :assets do - gem 'sass-rails', '~> 3.2.3' - gem 'coffee-rails', '~> 3.2.1' - - # See https://github.com/sstephenson/execjs#readme for more supported runtimes - # gem 'therubyracer' - - gem 'uglifier', '>= 1.0.3' -end - -gem 'jquery-rails' - -# To use ActiveModel has_secure_password -# gem 'bcrypt-ruby', '~> 3.0.0' - -# To use Jbuilder templates for JSON -# gem 'jbuilder' - -# Use unicorn as the app server -# gem 'unicorn' - -# Deploy with Capistrano -# gem 'capistrano' - -# To use debugger -# gem 'ruby-debug19', :require => 'ruby-debug' +source 'https://rubygems.org' + +gem 'rails', '3.2.2' + +# Bundle edge Rails instead: +# gem 'rails', :git => 'git://github.com/rails/rails.git' + +group :development, :test 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. +group :assets do + gem 'sass-rails', '~> 3.2.3' + gem 'coffee-rails', '~> 3.2.1' + + # See https://github.com/sstephenson/execjs#readme for more supported runtimes + # gem 'therubyracer' + + gem 'uglifier', '>= 1.0.3' +end + +gem 'jquery-rails' +gem 'cleditor_rails' +gem 'paperclip' + +# To use ActiveModel has_secure_password +# gem 'bcrypt-ruby', '~> 3.0.0' + +# To use Jbuilder templates for JSON +# gem 'jbuilder' + +# Use unicorn as the app server +# gem 'unicorn' + +# Deploy with Capistrano +# gem 'capistrano' + +# To use debugger +# gem 'ruby-debug19', :require => 'ruby-debug' + +gem 'json', '1.6.5' + diff --git a/Gemfile.lock b/Gemfile.lock index 81a3ba7..46ce106 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,111 +1,136 @@ -GEM - remote: https://rubygems.org/ - specs: - actionmailer (3.2.2) - actionpack (= 3.2.2) - mail (~> 2.4.0) - actionpack (3.2.2) - activemodel (= 3.2.2) - activesupport (= 3.2.2) - builder (~> 3.0.0) - erubis (~> 2.7.0) - journey (~> 1.0.1) - rack (~> 1.4.0) - rack-cache (~> 1.1) - rack-test (~> 0.6.1) - sprockets (~> 2.1.2) - activemodel (3.2.2) - activesupport (= 3.2.2) - builder (~> 3.0.0) - activerecord (3.2.2) - activemodel (= 3.2.2) - activesupport (= 3.2.2) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.2) - activemodel (= 3.2.2) - activesupport (= 3.2.2) - activesupport (3.2.2) - i18n (~> 0.6) - multi_json (~> 1.0) - arel (3.0.2) - builder (3.0.0) - coffee-rails (3.2.2) - coffee-script (>= 2.2.0) - railties (~> 3.2.0) - coffee-script (2.2.0) - coffee-script-source - execjs - coffee-script-source (1.2.0) - erubis (2.7.0) - execjs (1.3.0) - multi_json (~> 1.0) - hike (1.2.1) - i18n (0.6.0) - journey (1.0.3) - jquery-rails (2.0.1) - railties (>= 3.2.0, < 5.0) - thor (~> 0.14) - json (1.6.5) - mail (2.4.4) - i18n (>= 0.4.0) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mime-types (1.17.2) - multi_json (1.1.0) - polyglot (0.3.3) - rack (1.4.1) - rack-cache (1.2) - rack (>= 0.4) - rack-ssl (1.3.2) - rack - rack-test (0.6.1) - rack (>= 1.0) - rails (3.2.2) - actionmailer (= 3.2.2) - actionpack (= 3.2.2) - activerecord (= 3.2.2) - activeresource (= 3.2.2) - activesupport (= 3.2.2) - bundler (~> 1.0) - railties (= 3.2.2) - railties (3.2.2) - actionpack (= 3.2.2) - activesupport (= 3.2.2) - rack-ssl (~> 1.3.2) - rake (>= 0.8.7) - rdoc (~> 3.4) - thor (~> 0.14.6) - rake (0.9.2.2) - rdoc (3.12) - json (~> 1.4) - sass (3.1.15) - sass-rails (3.2.4) - railties (~> 3.2.0) - sass (>= 3.1.10) - tilt (~> 1.3) - sprockets (2.1.2) - hike (~> 1.2) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.5) - thor (0.14.6) - tilt (1.3.3) - treetop (1.4.10) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.32) - uglifier (1.2.3) - execjs (>= 0.3.0) - multi_json (>= 1.0.2) - -PLATFORMS - ruby - -DEPENDENCIES - coffee-rails (~> 3.2.1) - jquery-rails - rails (= 3.2.2) - sass-rails (~> 3.2.3) - sqlite3 - uglifier (>= 1.0.3) +GEM + remote: https://rubygems.org/ + specs: + actionmailer (3.2.2) + actionpack (= 3.2.2) + mail (~> 2.4.0) + actionpack (3.2.2) + activemodel (= 3.2.2) + activesupport (= 3.2.2) + builder (~> 3.0.0) + erubis (~> 2.7.0) + journey (~> 1.0.1) + rack (~> 1.4.0) + rack-cache (~> 1.1) + rack-test (~> 0.6.1) + sprockets (~> 2.1.2) + activemodel (3.2.2) + activesupport (= 3.2.2) + builder (~> 3.0.0) + activerecord (3.2.2) + activemodel (= 3.2.2) + activesupport (= 3.2.2) + arel (~> 3.0.2) + tzinfo (~> 0.3.29) + activeresource (3.2.2) + activemodel (= 3.2.2) + activesupport (= 3.2.2) + activesupport (3.2.2) + 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) + coffee-script (2.2.0) + 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) + hike (1.2.1) + i18n (0.6.0) + journey (1.0.3) + jquery-rails (2.0.1) + railties (>= 3.2.0, < 5.0) + thor (~> 0.14) + json (1.6.5) + mail (2.4.4) + i18n (>= 0.4.0) + mime-types (~> 1.16) + 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-x86-mingw32) + polyglot (0.3.3) + rack (1.4.1) + rack-cache (1.2) + rack (>= 0.4) + rack-ssl (1.3.2) + rack + rack-test (0.6.1) + rack (>= 1.0) + rails (3.2.2) + actionmailer (= 3.2.2) + actionpack (= 3.2.2) + activerecord (= 3.2.2) + activeresource (= 3.2.2) + activesupport (= 3.2.2) + bundler (~> 1.0) + railties (= 3.2.2) + railties (3.2.2) + actionpack (= 3.2.2) + activesupport (= 3.2.2) + rack-ssl (~> 1.3.2) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (~> 0.14.6) + rake (0.9.2.2) + rdoc (3.12) + json (~> 1.4) + sass (3.1.15) + sass-rails (3.2.4) + railties (~> 3.2.0) + sass (>= 3.1.10) + tilt (~> 1.3) + sprockets (2.1.2) + hike (~> 1.2) + 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) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.32) + 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 + json (= 1.6.5) + paperclip + pg + rails (= 3.2.2) + sass-rails (~> 3.2.3) + sqlite3 + uglifier (>= 1.0.3) diff --git a/Gemfile~ b/Gemfile~ new file mode 100644 index 0000000..3626fa1 --- /dev/null +++ b/Gemfile~ @@ -0,0 +1,40 @@ +source 'https://rubygems.org' + +gem 'rails', '3.2.2' + +# Bundle edge Rails instead: +# gem 'rails', :git => 'git://github.com/rails/rails.git' + +gem 'sqlite3' + +gem 'devise' + +# Gems used only for assets and not required +# in production environments by default. +group :assets do + gem 'sass-rails', '~> 3.2.3' + gem 'coffee-rails', '~> 3.2.1' + + # See https://github.com/sstephenson/execjs#readme for more supported runtimes + # gem 'therubyracer' + + gem 'uglifier', '>= 1.0.3' +end + +gem 'jquery-rails' +gem 'cleditor-rails' + +# To use ActiveModel has_secure_password +# gem 'bcrypt-ruby', '~> 3.0.0' + +# To use Jbuilder templates for JSON +# gem 'jbuilder' + +# Use unicorn as the app server +# gem 'unicorn' + +# Deploy with Capistrano +# gem 'capistrano' + +# To use debugger +# gem 'ruby-debug19', :require => 'ruby-debug' diff --git a/README.rdoc b/README.rdoc index 7c36f23..0f00a42 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,261 +1,261 @@ -== Welcome to Rails - -Rails is a web-application framework that includes everything needed to create -database-backed web applications according to the Model-View-Control pattern. - -This pattern splits the view (also called the presentation) into "dumb" -templates that are primarily responsible for inserting pre-built data in between -HTML tags. The model contains the "smart" domain objects (such as Account, -Product, Person, Post) that holds all the business logic and knows how to -persist themselves to a database. The controller handles the incoming requests -(such as Save New Account, Update Product, Show Post) by manipulating the model -and directing data to the view. - -In Rails, the model is handled by what's called an object-relational mapping -layer entitled Active Record. This layer allows you to present the data from -database rows as objects and embellish these data objects with business logic -methods. You can read more about Active Record in -link:files/vendor/rails/activerecord/README.html. - -The controller and view are handled by the Action Pack, which handles both -layers by its two parts: Action View and Action Controller. These two layers -are bundled in a single package due to their heavy interdependence. This is -unlike the relationship between the Active Record and Action Pack that is much -more separate. Each of these packages can be used independently outside of -Rails. You can read more about Action Pack in -link:files/vendor/rails/actionpack/README.html. - - -== Getting Started - -1. At the command prompt, create a new Rails application: - rails new myapp (where myapp is the application name) - -2. Change directory to myapp and start the web server: - cd myapp; rails server (run with --help for options) - -3. Go to http://localhost:3000/ and you'll see: - "Welcome aboard: You're riding Ruby on Rails!" - -4. Follow the guidelines to start developing your application. You can find -the following resources handy: - -* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html -* Ruby on Rails Tutorial Book: http://www.railstutorial.org/ - - -== Debugging Rails - -Sometimes your application goes wrong. Fortunately there are a lot of tools that -will help you debug it and get it back on the rails. - -First area to check is the application log files. Have "tail -f" commands -running on the server.log and development.log. Rails will automatically display -debugging and runtime information to these files. Debugging info will also be -shown in the browser on requests from 127.0.0.1. - -You can also log your own messages directly into the log file from your code -using the Ruby logger class from inside your controllers. Example: - - class WeblogController < ActionController::Base - def destroy - @weblog = Weblog.find(params[:id]) - @weblog.destroy - logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!") - end - end - -The result will be a message in your log file along the lines of: - - Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1! - -More information on how to use the logger is at http://www.ruby-doc.org/core/ - -Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are -several books available online as well: - -* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe) -* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide) - -These two books will bring you up to speed on the Ruby language and also on -programming in general. - - -== Debugger - -Debugger support is available through the debugger command when you start your -Mongrel or WEBrick server with --debugger. This means that you can break out of -execution at any point in the code, investigate and change the model, and then, -resume execution! You need to install ruby-debug to run the server in debugging -mode. With gems, use sudo gem install ruby-debug. Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.all - debugger - end - end - -So the controller will accept the action, run the first line, then present you -with a IRB prompt in the server window. Here you can do things like: - - >> @posts.inspect - => "[#nil, "body"=>nil, "id"=>"1"}>, - #"Rails", "body"=>"Only ten..", "id"=>"2"}>]" - >> @posts.first.title = "hello from a debugger" - => "hello from a debugger" - -...and even better, you can examine how your runtime objects actually work: - - >> f = @posts.first - => #nil, "body"=>nil, "id"=>"1"}> - >> f. - Display all 152 possibilities? (y or n) - -Finally, when you're ready to resume execution, you can enter "cont". - - -== Console - -The console is a Ruby shell, which allows you to interact with your -application's domain model. Here you'll have all parts of the application -configured, just like it is when the application is running. You can inspect -domain models, change values, and save to the database. Starting the script -without arguments will launch it in the development environment. - -To start the console, run rails console from the application -directory. - -Options: - -* Passing the -s, --sandbox argument will rollback any modifications - made to the database. -* Passing an environment name as an argument will load the corresponding - environment. Example: rails console production. - -To reload your controllers and models after launching the console run -reload! - -More information about irb can be found at: -link:http://www.rubycentral.org/pickaxe/irb.html - - -== dbconsole - -You can go to the command line of your database directly through rails -dbconsole. You would be connected to the database with the credentials -defined in database.yml. Starting the script without arguments will connect you -to the development database. Passing an argument will connect you to a different -database, like rails dbconsole production. Currently works for MySQL, -PostgreSQL and SQLite 3. - -== Description of Contents - -The default directory structure of a generated Ruby on Rails application: - - |-- app - | |-- assets - | |-- images - | |-- javascripts - | `-- stylesheets - | |-- controllers - | |-- helpers - | |-- mailers - | |-- models - | `-- views - | `-- layouts - |-- config - | |-- environments - | |-- initializers - | `-- locales - |-- db - |-- doc - |-- lib - | `-- tasks - |-- log - |-- public - |-- script - |-- test - | |-- fixtures - | |-- functional - | |-- integration - | |-- performance - | `-- unit - |-- tmp - | |-- cache - | |-- pids - | |-- sessions - | `-- sockets - `-- vendor - |-- assets - `-- stylesheets - `-- plugins - -app - Holds all the code that's specific to this particular application. - -app/assets - Contains subdirectories for images, stylesheets, and JavaScript files. - -app/controllers - Holds controllers that should be named like weblogs_controller.rb for - automated URL mapping. All controllers should descend from - ApplicationController which itself descends from ActionController::Base. - -app/models - Holds models that should be named like post.rb. Models descend from - ActiveRecord::Base by default. - -app/views - Holds the template files for the view that should be named like - weblogs/index.html.erb for the WeblogsController#index action. All views use - eRuby syntax by default. - -app/views/layouts - Holds the template files for layouts to be used with views. This models the - common header/footer method of wrapping views. In your views, define a layout - using the layout :default and create a file named default.html.erb. - Inside default.html.erb, call <% yield %> to render the view using this - layout. - -app/helpers - Holds view helpers that should be named like weblogs_helper.rb. These are - generated for you automatically when using generators for controllers. - Helpers can be used to wrap functionality for your views into methods. - -config - Configuration files for the Rails environment, the routing map, the database, - and other dependencies. - -db - Contains the database schema in schema.rb. db/migrate contains all the - sequence of Migrations for your schema. - -doc - This directory is where your application documentation will be stored when - generated using rake doc:app - -lib - Application specific libraries. Basically, any kind of custom code that - doesn't belong under controllers, models, or helpers. This directory is in - the load path. - -public - The directory available for the web server. Also contains the dispatchers and the - default HTML files. This should be set as the DOCUMENT_ROOT of your web - server. - -script - Helper scripts for automation and generation. - -test - Unit and functional tests along with fixtures. When using the rails generate - command, template test files will be generated for you and placed in this - directory. - -vendor - External libraries that the application depends on. Also includes the plugins - subdirectory. If the app has frozen rails, those gems also go here, under - vendor/rails/. This directory is in the load path. +== Welcome to Rails + +Rails is a web-application framework that includes everything needed to create +database-backed web applications according to the Model-View-Control pattern. + +This pattern splits the view (also called the presentation) into "dumb" +templates that are primarily responsible for inserting pre-built data in between +HTML tags. The model contains the "smart" domain objects (such as Account, +Product, Person, Post) that holds all the business logic and knows how to +persist themselves to a database. The controller handles the incoming requests +(such as Save New Account, Update Product, Show Post) by manipulating the model +and directing data to the view. + +In Rails, the model is handled by what's called an object-relational mapping +layer entitled Active Record. This layer allows you to present the data from +database rows as objects and embellish these data objects with business logic +methods. You can read more about Active Record in +link:files/vendor/rails/activerecord/README.html. + +The controller and view are handled by the Action Pack, which handles both +layers by its two parts: Action View and Action Controller. These two layers +are bundled in a single package due to their heavy interdependence. This is +unlike the relationship between the Active Record and Action Pack that is much +more separate. Each of these packages can be used independently outside of +Rails. You can read more about Action Pack in +link:files/vendor/rails/actionpack/README.html. + + +== Getting Started + +1. At the command prompt, create a new Rails application: + rails new myapp (where myapp is the application name) + +2. Change directory to myapp and start the web server: + cd myapp; rails server (run with --help for options) + +3. Go to http://localhost:3000/ and you'll see: + "Welcome aboard: You're riding Ruby on Rails!" + +4. Follow the guidelines to start developing your application. You can find +the following resources handy: + +* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html +* Ruby on Rails Tutorial Book: http://www.railstutorial.org/ + + +== Debugging Rails + +Sometimes your application goes wrong. Fortunately there are a lot of tools that +will help you debug it and get it back on the rails. + +First area to check is the application log files. Have "tail -f" commands +running on the server.log and development.log. Rails will automatically display +debugging and runtime information to these files. Debugging info will also be +shown in the browser on requests from 127.0.0.1. + +You can also log your own messages directly into the log file from your code +using the Ruby logger class from inside your controllers. Example: + + class WeblogController < ActionController::Base + def destroy + @weblog = Weblog.find(params[:id]) + @weblog.destroy + logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!") + end + end + +The result will be a message in your log file along the lines of: + + Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1! + +More information on how to use the logger is at http://www.ruby-doc.org/core/ + +Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are +several books available online as well: + +* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe) +* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide) + +These two books will bring you up to speed on the Ruby language and also on +programming in general. + + +== Debugger + +Debugger support is available through the debugger command when you start your +Mongrel or WEBrick server with --debugger. This means that you can break out of +execution at any point in the code, investigate and change the model, and then, +resume execution! You need to install ruby-debug to run the server in debugging +mode. With gems, use sudo gem install ruby-debug. Example: + + class WeblogController < ActionController::Base + def index + @posts = Post.all + debugger + end + end + +So the controller will accept the action, run the first line, then present you +with a IRB prompt in the server window. Here you can do things like: + + >> @posts.inspect + => "[#nil, "body"=>nil, "id"=>"1"}>, + #"Rails", "body"=>"Only ten..", "id"=>"2"}>]" + >> @posts.first.title = "hello from a debugger" + => "hello from a debugger" + +...and even better, you can examine how your runtime objects actually work: + + >> f = @posts.first + => #nil, "body"=>nil, "id"=>"1"}> + >> f. + Display all 152 possibilities? (y or n) + +Finally, when you're ready to resume execution, you can enter "cont". + + +== Console + +The console is a Ruby shell, which allows you to interact with your +application's domain model. Here you'll have all parts of the application +configured, just like it is when the application is running. You can inspect +domain models, change values, and save to the database. Starting the script +without arguments will launch it in the development environment. + +To start the console, run rails console from the application +directory. + +Options: + +* Passing the -s, --sandbox argument will rollback any modifications + made to the database. +* Passing an environment name as an argument will load the corresponding + environment. Example: rails console production. + +To reload your controllers and models after launching the console run +reload! + +More information about irb can be found at: +link:http://www.rubycentral.org/pickaxe/irb.html + + +== dbconsole + +You can go to the command line of your database directly through rails +dbconsole. You would be connected to the database with the credentials +defined in database.yml. Starting the script without arguments will connect you +to the development database. Passing an argument will connect you to a different +database, like rails dbconsole production. Currently works for MySQL, +PostgreSQL and SQLite 3. + +== Description of Contents + +The default directory structure of a generated Ruby on Rails application: + + |-- app + | |-- assets + | |-- images + | |-- javascripts + | `-- stylesheets + | |-- controllers + | |-- helpers + | |-- mailers + | |-- models + | `-- views + | `-- layouts + |-- config + | |-- environments + | |-- initializers + | `-- locales + |-- db + |-- doc + |-- lib + | `-- tasks + |-- log + |-- public + |-- script + |-- test + | |-- fixtures + | |-- functional + | |-- integration + | |-- performance + | `-- unit + |-- tmp + | |-- cache + | |-- pids + | |-- sessions + | `-- sockets + `-- vendor + |-- assets + `-- stylesheets + `-- plugins + +app + Holds all the code that's specific to this particular application. + +app/assets + Contains subdirectories for images, stylesheets, and JavaScript files. + +app/controllers + Holds controllers that should be named like weblogs_controller.rb for + automated URL mapping. All controllers should descend from + ApplicationController which itself descends from ActionController::Base. + +app/models + Holds models that should be named like post.rb. Models descend from + ActiveRecord::Base by default. + +app/views + Holds the template files for the view that should be named like + weblogs/index.html.erb for the WeblogsController#index action. All views use + eRuby syntax by default. + +app/views/layouts + Holds the template files for layouts to be used with views. This models the + common header/footer method of wrapping views. In your views, define a layout + using the layout :default and create a file named default.html.erb. + Inside default.html.erb, call <% yield %> to render the view using this + layout. + +app/helpers + Holds view helpers that should be named like weblogs_helper.rb. These are + generated for you automatically when using generators for controllers. + Helpers can be used to wrap functionality for your views into methods. + +config + Configuration files for the Rails environment, the routing map, the database, + and other dependencies. + +db + Contains the database schema in schema.rb. db/migrate contains all the + sequence of Migrations for your schema. + +doc + This directory is where your application documentation will be stored when + generated using rake doc:app + +lib + Application specific libraries. Basically, any kind of custom code that + doesn't belong under controllers, models, or helpers. This directory is in + the load path. + +public + The directory available for the web server. Also contains the dispatchers and the + default HTML files. This should be set as the DOCUMENT_ROOT of your web + server. + +script + Helper scripts for automation and generation. + +test + Unit and functional tests along with fixtures. When using the rails generate + command, template test files will be generated for you and placed in this + directory. + +vendor + External libraries that the application depends on. Also includes the plugins + subdirectory. If the app has frozen rails, those gems also go here, under + vendor/rails/. This directory is in the load path. diff --git a/Rakefile b/Rakefile index 8d9611e..adc01ca 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ -#!/usr/bin/env rake -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. - -require File.expand_path('../config/application', __FILE__) - -Planet::Application.load_tasks +#!/usr/bin/env rake +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Planet::Application.load_tasks diff --git a/app/assets/images/alberto.jpg b/app/assets/images/alberto.jpg new file mode 100644 index 0000000..58923a4 Binary files /dev/null and b/app/assets/images/alberto.jpg differ diff --git a/app/assets/images/alberto_contador.jpg b/app/assets/images/alberto_contador.jpg new file mode 100644 index 0000000..cb6d270 Binary files /dev/null and b/app/assets/images/alberto_contador.jpg differ diff --git a/app/assets/images/francisco.jpg b/app/assets/images/francisco.jpg new file mode 100644 index 0000000..a1be5bc Binary files /dev/null and b/app/assets/images/francisco.jpg differ diff --git a/app/assets/images/pizarro.jpg b/app/assets/images/pizarro.jpg new file mode 100644 index 0000000..77b4915 Binary files /dev/null and b/app/assets/images/pizarro.jpg differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 9097d83..1d4dbd6 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -1,15 +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 jquery_ujs -//= require_tree . +// 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 jquery_ujs +//= require_tree . +//= require cleditor diff --git a/app/assets/javascripts/application.js~ b/app/assets/javascripts/application.js~ new file mode 100644 index 0000000..c690d2a --- /dev/null +++ b/app/assets/javascripts/application.js~ @@ -0,0 +1,15 @@ +// 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 jquery_ujs +//= require_tree . diff --git a/app/assets/javascripts/comments.js.coffee b/app/assets/javascripts/comments.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/comments.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/planet.js.coffee b/app/assets/javascripts/planet.js.coffee index 7615679..b3f5f37 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/ +# 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/sites.js.coffee b/app/assets/javascripts/sites.js.coffee index 7615679..b3f5f37 100644 --- a/app/assets/javascripts/sites.js.coffee +++ b/app/assets/javascripts/sites.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/ +# 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.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/types.js.coffee b/app/assets/javascripts/types.js.coffee index 7615679..b3f5f37 100644 --- a/app/assets/javascripts/types.js.coffee +++ b/app/assets/javascripts/types.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/ +# 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/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..ce0584f 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1,13 +1,14 @@ -/* - * This is a manifest file that'll be compiled into application.css, which will include all the files - * listed below. - * - * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, - * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. - * - * You're free to add application-wide styles to this file and they'll appear at the top of the - * compiled file, but it's generally better to create a new file per style scope. - * - *= require_self - *= require_tree . -*/ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the top of the + * compiled file, but it's generally better to create a new file per style scope. + * + *= require_self + *= require cleditor + *= require_tree . +*/ diff --git a/app/assets/stylesheets/application.css~ b/app/assets/stylesheets/application.css~ new file mode 100644 index 0000000..4561cc1 --- /dev/null +++ b/app/assets/stylesheets/application.css~ @@ -0,0 +1,13 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the top of the + * compiled file, but it's generally better to create a new file per style scope. + * + *= require_self + *= require_tree . +*/ diff --git a/app/assets/stylesheets/comments.css.scss b/app/assets/stylesheets/comments.css.scss new file mode 100644 index 0000000..3722c12 --- /dev/null +++ b/app/assets/stylesheets/comments.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the comments 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 index 28c4fcc..0169dae 100644 --- a/app/assets/stylesheets/planet.css +++ b/app/assets/stylesheets/planet.css @@ -1,157 +1,197 @@ -/* 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_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 .list_description dd { - margin: 0; -} - -#site_list .list_actions { - font-size: x-small; - text-align: right; - padding-left: 1em; -} - -#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; -} - -#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; -} +/* 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; + margin-top: 30px; +} + +/* Styles for products/index */ + +#site_list table { + border-collapse: collapse; + margin-bottom: 1em; + margin-top: 1em; +} + +#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 .list_description dd { + margin: 0; +} + +#site_list .list_actions { + font-size: x-small; + text-align: right; + padding-left: 1em; +} + +#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; +} + +#columns { + background: #446; +} + +#main { + margin-left: 14em; /* Ajuste de borde izquierdo */ + padding-top: 4ex; + padding-left: 2em; + background: white; +} + +#main .links_down{ + margin-top: 2em; +} + +#main .links_up{ + margin-bottom: 2em; +} + +#map_canvas { + width: 100%; + height: 600px; +} + +#options { + margin-top: 30px; +} + +#planet .user { + float: right; + color: #bfb; + font-size: small; +} + +#search_form .long_min{ + margin-top: 2em; + margin-bottom: 1em; +} + +#search_form { + margin-top: 2em; + margin-bottom: 2em; +} + +#side { + float: left; + padding-top: 1em; + padding-left: 1em; + padding-bottom: 1em; + background: #446; + width: 13em; +} + +#side a { + color: #bfb; + font-size: small; +} + +#site .visitas { + text-indent: 70%; +} +/* 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; +} diff --git a/app/assets/stylesheets/planet.css.scss b/app/assets/stylesheets/planet.css.scss index 749d901..1689f9f 100644 --- a/app/assets/stylesheets/planet.css.scss +++ b/app/assets/stylesheets/planet.css.scss @@ -1,3 +1,3 @@ -// Place all the styles related to the planet controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ +// Place all the styles related to the planet 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/sites.css.scss b/app/assets/stylesheets/sites.css.scss index 682e55c..4708097 100644 --- a/app/assets/stylesheets/sites.css.scss +++ b/app/assets/stylesheets/sites.css.scss @@ -1,3 +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/ +// 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/ 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/types.css.scss b/app/assets/stylesheets/types.css.scss index ea4c6db..dddea8f 100644 --- a/app/assets/stylesheets/types.css.scss +++ b/app/assets/stylesheets/types.css.scss @@ -1,3 +1,3 @@ -// Place all the styles related to the types controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ +// Place all the styles related to the types 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..2067b9c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,3 @@ -class ApplicationController < ActionController::Base - protect_from_forgery -end +class ApplicationController < ActionController::Base + protect_from_forgery +end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb new file mode 100644 index 0000000..aedaf41 --- /dev/null +++ b/app/controllers/comments_controller.rb @@ -0,0 +1,109 @@ +# == Qué hace este controlador +# El controlador de comments gestiona todo lo relacionado con la creación, +# edición y eliminación de comentarios. Trabaja con Devise para identificar +# cada comentario con el usuario que lo creó. +# Tiene un filtro para ejecutar las acciones sólo si se ha iniciado sesión. +# Este filtro no afecta a las acciones index y show. +class CommentsController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # Método que muestra los comentarios asociados al sitio seleccionado. Rutas: + # * GET /sites/:site_id/comments + # * GET /sites/:site_id/comments.json + def index + @site = Site.find(params[:site_id]) + @comments = @site.comments + @comment = current_user.comments.build if current_user + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @comments } + end + end + + # Método que muestra el comentario seleccionado. Rutas: + # * GET /comments/:comment_id + # * GET /comments/:comment_id.json + def show + @comment = Comment.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @comment } + end + end + + # Método que permite modificar un nuevo comentario asociado a un sitio. Rutas: + # * GET /sites/:site_id/comments/new + # * GET /sites/:site_id/comments/new.json + def new + @comment = current_user.comments.build + @site = Site.find(params[:site_id]) + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @comment } + end + end + + # Método que permite editar el comentario seleccionado. Ruta: + # * GET /comments/:id/edit + def edit + @comment = current_user.comments.find(params[:id]) + @site = @comment.site + end + + # Método que crea el nuevo comentario. Rutas: + # * POST /comments + # * POST /comments.js + # * POST /comments.json + def create + @comment = current_user.comments.build(params[:comment]) + @site = @comment.site + + respond_to do |format| + if @comment.save + format.html { redirect_to site_path(@site), notice: 'Comment was successfully created.' } + format.js + format.json { render json: @comment, status: :created, location: @comment } + else + format.html { render action: "new" } + format.json { render json: @comment.errors, status: :unprocessable_entity } + end + end + end + + # Método que actualiza el comentario editado. Rutas: + # * PUT /comments/:id + # * PUT /comments/:id.json + def update + @comment = current_user.comments.find(params[:id]) + @site = @comment.site + + respond_to do |format| + if @comment.update_attributes(params[:comment]) + format.html { redirect_to site_path(@site), notice: 'Comment was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @comment.errors, status: :unprocessable_entity } + end + end + end + + # Método que permite eliminar un comentario. Rutas: + # * DELETE /comments/:id + # * DELETE /comments/:id.json + def destroy + @comment = current_user.comments.find(params[:id]) + site = @comment.site + @comment.destroy + + respond_to do |format| + format.html { redirect_to site_path(site) } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/comments_controller.rb~ b/app/controllers/comments_controller.rb~ new file mode 100644 index 0000000..83be975 --- /dev/null +++ b/app/controllers/comments_controller.rb~ @@ -0,0 +1,96 @@ +# == Qué hace este controlador +# El controlador de comments gestiona todo lo relacionado con la creación, edición y eliminación de comentarios. Trabaja con Devise para identificar cada comentario con el usuario que lo creó. +class CommentsController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # GET /comments + # GET /comments.json + def index + @site = Site.find(params[:site_id]) + @comments = @site.comments + @comment = current_user.comments.build if current_user + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @comments } + end + end + + # GET /comments/1 + # GET /comments/1.json + def show + @comment = Comment.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @comment } + end + end + + # GET /comments/new + # GET /comments/new.json + def new + @comment = current_user.comments.build + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @comment } + end + end + + # GET /comments/1/edit + def edit + @comment = current_user.comments.find(params[:id]) + @site = @comment.site + end + + # POST /comments + # POST /comments.json + def create + @comment = current_user.comments.build(params[:comment]) + @site = @comment.site + + respond_to do |format| + if @comment.save + format.html { redirect_to site_path(@site), notice: 'Comment was successfully created.' } + format.js + format.json { render json: @comment, status: :created, location: @comment } + else + format.html { render action: "new" } + format.json { render json: @comment.errors, status: :unprocessable_entity } + end + end + end + + # PUT /comments/1 + # PUT /comments/1.json + def update + @comment = current_user.comments.find(params[:id]) + @site = @comment.site + + respond_to do |format| + if @comment.update_attributes(params[:comment]) + format.html { redirect_to site_path(@site), notice: 'Comment was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @comment.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /comments/1 + # DELETE /comments/1.json + def destroy + @comment = current_user.comments.find(params[:id]) + site = @comment.site + @comment.destroy + + respond_to do |format| + format.html { redirect_to site_path(site) } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/planet_controller.rb b/app/controllers/planet_controller.rb index be7ac0a..21ecd2a 100644 --- a/app/controllers/planet_controller.rb +++ b/app/controllers/planet_controller.rb @@ -1,11 +1,60 @@ -class PlanetController < ApplicationController - def index - end - - def contact - end - - def ejemplo - end - -end +# 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 +# +# == Qué hace este controlador +# El controlador de planet es en gran parte un controlador de prueba con acciones vacías. Sólo hay un método con una acción +# completa, search. Esta acción busca los sitios o viajes que tengan en su nombre o en su descripción la cadena de texto introducida. +class PlanetController < ApplicationController + + # Método que define una acción vacía del controlador. Ruta: + # * GET /planet/index + def index + end + + # Método que define una acción vacía del controlador. Ruta: + # * GET /planet/contact + def contact + end + + # Método que define una acción vacía del controlador. Ruta: + # * GET /planet/ejemplo + def ejemplo + end + + # Método que define una acción vacía del controlador. Ruta: + # * GET /planet/author + def author + end + + # Método que permite buscar por nombre y descripción sitios y viajes. Ruta: + # * GET /planet/search + def search + search = "%#{params[:search]}%" + @sites = Site.find(:all, :conditions => ['name LIKE ? or description LIKE ?', search, search]) + @trips = Trip.find(:all, :conditions => ['name LIKE ? or description LIKE ?', search, search]) + + respond_to do |format| + format.html + format.json { render json: @sites } + format.json { render json: @trips } + end + end +end diff --git a/app/controllers/planet_controller.rb~ b/app/controllers/planet_controller.rb~ new file mode 100644 index 0000000..ccdbb70 --- /dev/null +++ b/app/controllers/planet_controller.rb~ @@ -0,0 +1,46 @@ +# 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 + # 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 ejemplo + end + # Método que define una acción vacía del controlador + def author + end + # Método que permite buscar por nombre sitios y viajes + def search + @sites = Site.find(:all, :conditions => ['name LIKE ? or description LIKE ?', "%#{params[:search]}%", "%#{params[:search]}%"]) + @trips = Trip.find(:all, :conditions => ['name LIKE ? or description LIKE ?', "%#{params[:search]}%", "%#{params[:search]}%"]) + + respond_to do |format| + format.html + format.json { render json: @sites } + format.json { render json: @trips } + end + end +end diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index f3ae9ad..e1b0ea2 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -1,86 +1,112 @@ -class SitesController < ApplicationController - # 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 } - end - end - - # GET /sites/new - # GET /sites/new.json - def new - @site = Site.new - - respond_to do |format| - format.html # new.html.erb - format.json { render json: @site } - end - end - - # GET /sites/1/edit - def edit - @site = Site.find(params[:id]) - end - - # POST /sites - # POST /sites.json - def create - @site = Site.new(params[:site]) - - 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 = Site.find(params[:id]) - - 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 = Site.find(params[:id]) - @site.destroy - - respond_to do |format| - format.html { redirect_to sites_url } - format.json { head :no_content } - end - end -end +# == Qué hace este controlador +# El controlador de sites gestiona todo lo relacionado con la creación, edición y eliminación de sitios. +# Trabaja con Devise para identificar cada sitio con el usuario que lo creó. +# Tiene dos filtros: +# * Uno para ejecutar las acciones sólo si antes se ha iniciado sesión. Este filtro no afecta a las acciones index y show. +# * Otro para ejecutar el método que define la acción count_visita después de la carga de la página. +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 + + # Este método muestra todos los sitios si no se ha especificado un tipo o los sitios de un tipo determinado. Rutas: + # * GET /sites + # * GET /sites.json + def index + if params[:type_id].nil? or params[:type_id].empty? + @sites = Site.all # path: /sites + else + @sites = Type.find(params[:type_id]).sites # path: /types/:type_id/sites + end + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @sites } + end + end + + # Método que muestra el sitio seleccionado. Rutas: + # * GET /sites/:id + # * GET /sites/:id.json + def show + @site = Site.find(params[:id]) + @comment = current_user.comments.build if current_user + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @site } + end + end + + # Método que permite modificar un nuevo sitio. Rutas: + # * 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 + + # Método que permite editar el sitio seleccionado. Ruta: + # * GET /sites/:id/edit + def edit + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + end + + # Método que crea el nuevo sitio. Rutas: + # * 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 + + # Método que actualiza el sitio editado. Rutas: + # * PUT /sites/:id + # * PUT /sites/:id.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 + + # Método que permite eliminar un sitio. Rutas: + # * DELETE /sites/:id + # * DELETE /sites/:id.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 + + # Este método define una acción que incrementa el parámetro visitas del sitio actual. + 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..70bb48f --- /dev/null +++ b/app/controllers/sites_controller.rb~ @@ -0,0 +1,104 @@ +# == Qué hace este controlador +# El controlador de sites gestiona todo lo relacionado con la creación, edición y eliminación de sitios. Trabaja con Devise para identificar cada sitio con el usuario que lo creó. +# Tiene dos filtros: +# * Uno para ejecutar las acciones sólo si antes se ha iniciado sesión. Este filtro no afecta a las acciones index y show. +# * Otro para ejecutar el método que define la acción count_visita después de la carga de la página. +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 + # Esta método muestra todos los sitios si no se ha especificado un tipo ó los sitios de un tipo determinado + def index + if params[:type_id].nil? or params[:type_id].empty? + @sites = Site.all # path: /sites + 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]) + @comment = current_user.comments.build if current_user + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @site } + 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 + # Este método define una acción que incrementa el parámetro visitas del sitio actual. + 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..b82c8b1 --- /dev/null +++ b/app/controllers/trips_controller.rb @@ -0,0 +1,100 @@ +# == Qué hace este controlador +# El controlador de trips gestiona todo lo relacionado con la creación, edición y eliminación de viajes. +# Trabaja con Devise para identificar cada viaje con el usuario que lo creó y con visits, que componen un viaje. +# Tiene un filtro para ejecutar las acciones sólo si antes se ha iniciado sesión. Este filtro no afecta a las acciones index y show. + +class TripsController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # Método que muestra todos los viajes. Rutas: + # * 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 + + # Método que muestra el viaje seleccionado. Rutas: + # * GET /trips/:id + # * GET /trips/:id.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 + + # Método que permite modificar un nuevo viaje. Rutas: + # * 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 + + # Método que permite editar el viaje seleccionado. Ruta: + # * GET /trips/:id/edit + def edit + @trip = current_user.trips.find(params[:id]) + end + + # Método que crea el nuevo viaje. Rutas: + # * 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 + + # Método que actualiza el viaje editado. Rutas: + # * PUT /trips/:id + # * PUT /trips/:id.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 + + # Método que permite eliminar un viaje. Rutas: + # * DELETE /trips/:id + # * DELETE /trips/:id.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..57e3402 --- /dev/null +++ b/app/controllers/trips_controller.rb~ @@ -0,0 +1,92 @@ +# == Qué hace este controlador +# El controlador de trips gestiona todo lo relacionado con la creación, edición y eliminación de viajes. Trabaja con Devise para identificar cada viaje con el usuario que lo creó. +# Tiene un filtro para ejecutar las acciones sólo si antes se ha iniciado sesión. Este filtro no afecta a las acciones index y 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/types_controller.rb b/app/controllers/types_controller.rb index da826f4..48cd1b3 100644 --- a/app/controllers/types_controller.rb +++ b/app/controllers/types_controller.rb @@ -1,83 +1,106 @@ -class TypesController < ApplicationController - # 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 +# == Qué hace este controlador +# El controlador de tipos gestiona todo lo relacionado con la creación, edición y eliminación de tipos. +# Cualquier usuario puede realizar acciones sobre los tipos. +class TypesController < ApplicationController + + # Método que muestra todos los tipos. Rutas: + # * 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 + + # Método que muestra el tipo seleccionado. Rutas: + # * GET /types/:id + # * GET /types/:id.json + def show + @type = Type.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @type } + end + end + + # Este método define una acción que muestra todos los tipos por orden alfabético. Rutas: + # * GET /types/ordered_index + # * GET /types/ordered_index.json + def ordered_index + @types = Type.find(:all, :order => :name) + + respond_to do |format| + format.html # ordered_index.html.erb + format.json { render json: @types } + end + end + + # Método que permite modificar un nuevo tipo. Rutas: + # * 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 + + # Método que permite editar el tipo seleccionado. Ruta: + # * GET /types/:id/edit + def edit + @type = Type.find(params[:id]) + end + + # Método que crea el nuevo tipo. Rutas: + # * 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 + + # Método que actualiza el tipo editado. Rutas: + # * PUT /types/:id + # * PUT /types/:id.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 + + # Método que permite eliminar un tipo. Rutas: + # * DELETE /types/:id + # * DELETE /types/:id.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/types_controller.rb~ b/app/controllers/types_controller.rb~ new file mode 100644 index 0000000..cb92b41 --- /dev/null +++ b/app/controllers/types_controller.rb~ @@ -0,0 +1,96 @@ +# == Qué hace este controlador +# El controlador de tipos gestiona todo lo relacionado con la creación, edición y eliminación de tipos. Cualquier usuario puede realizar acciones sobre los tipos. +class TypesController < ApplicationController + # 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/ordered_index + # GET /types/ordered_index.json + def ordered_index + @types = Type.find(:all, :order => :name) + + respond_to do |format| + format.html # ordered_index.html.erb + format.json { render json: @types } + 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..299a9d6 --- /dev/null +++ b/app/controllers/visits_controller.rb @@ -0,0 +1,96 @@ +# == Qué hace este controlador +# El controlador de tipos gestiona todo lo relacionado con la creación, edición y eliminación de tipos. +# Como las visitas se renderizan con los viajes, se controla indirectamente qué usuario realiza estas acciones. +class VisitsController < ApplicationController + + # Método que muestra todos las visitas. Rutas: + # * 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 + + # Método que muestra la visita seleccionada. Rutas: + # * 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 + + # Método que permite modificar una nueva visita. Rutas: + # * 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 + + # Método que permite editar la visita seleccionada. Ruta: + # * GET /visits/1/edit + def edit + @visit = Visit.find(params[:id]) + end + + # Método que crea la nueva visita. Rutas: + # * POST /visits + # * POST /visits.js + # * 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 + + # Método que actualiza la visita editada. Rutas: + # * 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 + + # Método que permite eliminar una visita. Rutas: + # * 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..f63b1ea --- /dev/null +++ b/app/controllers/visits_controller.rb~ @@ -0,0 +1,86 @@ +# == Qué hace este controlador +# El controlador de tipos gestiona todo lo relacionado con la creación, edición y eliminación de tipos. Como las visitas se renderizan con los viajes, se controla quién realiza estas acciones. +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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..bf7774a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,2 @@ -module ApplicationHelper -end +module ApplicationHelper +end diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb new file mode 100644 index 0000000..0ec9ca5 --- /dev/null +++ b/app/helpers/comments_helper.rb @@ -0,0 +1,2 @@ +module CommentsHelper +end diff --git a/app/helpers/planet_helper.rb b/app/helpers/planet_helper.rb index 5bbc197..8d6fe81 100644 --- a/app/helpers/planet_helper.rb +++ b/app/helpers/planet_helper.rb @@ -1,2 +1,2 @@ -module PlanetHelper -end +module PlanetHelper +end diff --git a/app/helpers/sites_helper.rb b/app/helpers/sites_helper.rb index 621069d..0d211d7 100644 --- a/app/helpers/sites_helper.rb +++ b/app/helpers/sites_helper.rb @@ -1,2 +1,2 @@ -module SitesHelper -end +module SitesHelper +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/types_helper.rb b/app/helpers/types_helper.rb index 40a2b9e..7f3df02 100644 --- a/app/helpers/types_helper.rb +++ b/app/helpers/types_helper.rb @@ -1,2 +1,2 @@ -module TypesHelper -end +module TypesHelper +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/comment.rb b/app/models/comment.rb new file mode 100644 index 0000000..084af3d --- /dev/null +++ b/app/models/comment.rb @@ -0,0 +1,14 @@ +# == Qué define este modelo +# El modelo de comments define los comentarios que los usuarios hagan sobre los sitios. Cada comentario pertenece +# a un usuario y a un sitio determinado. Por defecto se ha establecido un máximo de 240 caracteres para cada comentario. +class Comment < ActiveRecord::Base + belongs_to :site + belongs_to :user + + # Debe estar protegido para evitar accesos indeseados + attr_protected :user_id + + # Se añaden estas definiciones + validates :comment, :presence => true, :length => { :maximum => 240 } # campo obligatorio + +end diff --git a/app/models/comment.rb~ b/app/models/comment.rb~ new file mode 100644 index 0000000..a78f161 --- /dev/null +++ b/app/models/comment.rb~ @@ -0,0 +1,14 @@ +# == Qué define este modelo +# El modelo de comments define los comentarios que los ususarios hagan sobre los sitios. Cada comentario pertenece +# a un usuario y a un sitio determinado. Por defecto se ha establecido un máximo de 240 caracteres para cada comentario. +class Comment < ActiveRecord::Base + belongs_to :site + belongs_to :user + + # Debe estar protegido para evitar accesos indeseados + attr_protected :user_id + + # Se añaden estas definiciones + validates :comment, :presence => true, :length => { :maximum => 240 } # campo obligatorio + +end diff --git a/app/models/site.rb b/app/models/site.rb index 3eb288d..39c5dea 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -1,3 +1,28 @@ -class Site < ActiveRecord::Base - belongs_to :type -end +# == Qué define este modelo +# El modelo de site define un sitio, un emplazamiento en alguna parte del mundo que se añade +# por su interés turístico, especificando su tipo. Un sitio pertenece al usuario que lo ha creado +# y al tipo en el que se enmarca. Sólo el usuario que lo ha creado podrá editarlo o borrarlo. +# Un sitio puede ser parte de muchos viajes definido como una visita. Además puede tener comentarios +# que añadan los usuarios y una imagen que lo identifique. +# Obligatoriamente un sitio tiene que tener un nombre y un tipo. + +class Site < ActiveRecord::Base + belongs_to :type + belongs_to :user + + has_many :visits + has_many :trips, :through => :visits + has_many :comments + + has_attached_file :image + + # Debe estar protegido para evitar accesos indeseados + attr_protected :user_id + + # Se añaden estas definiciones + validates :name, :type_id, :presence => true # campo obligatorio + #validates_numericality_of :latitud, :less_than => 90, :greater_than => -90 + #validates_numericality_of :longitud, :less_than_or_equal_to => 180, :greater_than_or_equal_to => -180 + #validates_numericality_of :zoom, :less_than => 20, :greater_than_or_equal_to => 0 + +end diff --git a/app/models/site.rb~ b/app/models/site.rb~ new file mode 100644 index 0000000..ae22f06 --- /dev/null +++ b/app/models/site.rb~ @@ -0,0 +1,25 @@ +# == Qué define este modelo +# El modelo de site define un sitio, un emplazamiento en alguna parte del mundo que se añade +# por su interés turístico, especificando su tipo. Un sitio pertenece al usuario que lo ha creado +# y al tipo en el que se enmarca. Sólo el usuario que lo ha creado podrá editarlo o borrarlo. +# Un sitio puede ser parte de muchos viajes definido como una visita. Además puede tener comentarios +# que añadan los usuarios y una imagen que lo identifique. + +# Obligatoriamente un sitio tiene que tener un nombre y un tipo. + +class Site < ActiveRecord::Base + belongs_to :type + belongs_to :user + + has_many :visits + has_many :trips, :through => :visits + has_many :comments + + has_attached_file :image + + # Debe estar protegido para evitar accesos indeseados + attr_protected :user_id + + # Se añaden estas definiciones + validates :name, :type_id, :presence => true # campo obligatorio +end diff --git a/app/models/trip.rb b/app/models/trip.rb new file mode 100644 index 0000000..c28583a --- /dev/null +++ b/app/models/trip.rb @@ -0,0 +1,12 @@ +# == Qué define este modelo +# El modelo de trips define los viajes que se pueden hacer. Cada viaje pertenece a un usuario determinado +# e incluye una serie de visitas (una serie de sitios a los que se pretende ir a una hora determinada). + +class Trip < ActiveRecord::Base + belongs_to :user + has_many :visits + has_many :sites, :through => :visits + + # Se añade relacion + attr_protected :user_id # Por seguridad +end diff --git a/app/models/trip.rb~ b/app/models/trip.rb~ new file mode 100644 index 0000000..8f58b97 --- /dev/null +++ b/app/models/trip.rb~ @@ -0,0 +1,10 @@ +# Modelo de Trip y User con relación uno-a-muchos: +# -> belongs_to :user referencia un objeto User +class Trip < ActiveRecord::Base + belongs_to :user + has_many :visits + has_many :sites, :through => :visits + + # Se añade relacion + attr_protected :user_id # Por seguridad +end diff --git a/app/models/type.rb b/app/models/type.rb index 7c3d2ac..d9e353d 100644 --- a/app/models/type.rb +++ b/app/models/type.rb @@ -1,3 +1,11 @@ -class Type < ActiveRecord::Base - has_many :sites -end +# == Qué define este modelo +# El modelo de types define los tipos o categorías en los que se puede clasificar cada sitio. Un tipo agrupa a varios sitios +# que comparten unas caracterícas determinadas (como por ejemplo estar en medio de la naturaleza o ser un edificio histórico). +# Un tipo tiene que tener obligatoriamente un nombre y una descripción, pero no pueden existir dos sitios con el mismo nombre. +class Type < ActiveRecord::Base + has_many :sites + + # Se añade esta definición de recurso + validates :name, :description, :presence => true # campo obligatorio + validates :name, :uniqueness => true # Campo único (no repetido) +end diff --git a/app/models/type.rb~ b/app/models/type.rb~ new file mode 100644 index 0000000..f41fa00 --- /dev/null +++ b/app/models/type.rb~ @@ -0,0 +1,7 @@ +class Type < ActiveRecord::Base + has_many :sites + + # Se añade esta definición de recurso + validates :name, :description, :presence => true # campo obligatorio + validates :name, :uniqueness => true # Campo único (no repetido) +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..27c22df --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,19 @@ +# == Qué define este modelo +# El modelo de users define los usuarios de esta página web. Cada persona debe crearse un usario que le identifique dentro +# de la página web, especificando un nombre, una contraseña para evitar accesos indeseados y la suplantación de su identidad y un correo para recibir avisos y recuperar la contraseña. +# Un usuario es dueño de todos los sitios, comentarios y viajes que haya creado, y como tal sólo él podrá editarlos o borrarlos. +class User < ActiveRecord::Base + has_many :sites + has_many :comments + has_many :trips + + # 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 diff --git a/app/models/user.rb~ b/app/models/user.rb~ new file mode 100644 index 0000000..671f708 --- /dev/null +++ b/app/models/user.rb~ @@ -0,0 +1,15 @@ +class User < ActiveRecord::Base + has_many :sites + has_many :comments + has_many :trips + + # 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 diff --git a/app/models/visit.rb b/app/models/visit.rb new file mode 100644 index 0000000..e4853ba --- /dev/null +++ b/app/models/visit.rb @@ -0,0 +1,6 @@ +# == Qué define este modelo +# El modelo de visits define las visitas que componen cada viaje, es decir, los sitios que se desean visitar en dicho viaje. +class Visit < ActiveRecord::Base + belongs_to :trip + belongs_to :site +end diff --git a/app/models/visit.rb~ b/app/models/visit.rb~ new file mode 100644 index 0000000..ca23b73 --- /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/comments/_comment.html.erb b/app/views/comments/_comment.html.erb new file mode 100644 index 0000000..ec80a87 --- /dev/null +++ b/app/views/comments/_comment.html.erb @@ -0,0 +1,28 @@ +
+ + <% @comments.each do |comment| %> + + + + + + + <% end %> +
+
+ <% if comment.user == current_user %> +
<%= link_to comment.user.name + ":", edit_user_registration_path %>
+ <% else %> +
<%= comment.user.name + ":" %>
+ <% end %> +
<%= strip_tags(comment.comment) %>
+
+
+ <% if comment.user == current_user %> + <%= link_to 'Edit', edit_comment_path(comment) %>
+ <%= link_to 'Destroy', comment, + :confirm => 'Are you sure?', + :method => :delete if comment.user == current_user %> + <% end %> +
+
\ No newline at end of file diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb new file mode 100644 index 0000000..d440de7 --- /dev/null +++ b/app/views/comments/_form.html.erb @@ -0,0 +1,21 @@ +<%= form_for(@comment, :remote => true) do |f| %> + <% if @comment.errors.any? %> +
+

<%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:

+ +
    + <% @comment.errors.full_messages.each do |msg| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.text_area :comment, :maxlength => 240, :rows => 6 %> +
+ <%= f.number_field :site_id, :value => @site.id, :hidden => true %> +
+ <%= f.submit 'Nuevo comentario' %> +
+<% end %> diff --git a/app/views/comments/_form.html.erb~ b/app/views/comments/_form.html.erb~ new file mode 100644 index 0000000..ab5f21a --- /dev/null +++ b/app/views/comments/_form.html.erb~ @@ -0,0 +1,33 @@ +<%= 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| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
+
+ <%= f.label :description %>
+ <%= f.text_area :description , :rows => 4 %> +
+
+ <%= f.label :type_id %>
+ <%= f.collection_select(:type_id, Type.find(:all, :order => :name), :id, :name) %> +
+
+ <%= f.label :image_url %>
+ <%= f.text_field :image_url %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb new file mode 100644 index 0000000..8e8985e --- /dev/null +++ b/app/views/comments/create.js.erb @@ -0,0 +1,4 @@ +// Programa jQuery/Javascript +// -> sustituye la lista de comentarios de un sitio en DOM +// -> HTML se genera en servidor con ERb +$('#comment').html("<%= j render @comment.site %>"); diff --git a/app/views/comments/create.js.erb~ b/app/views/comments/create.js.erb~ new file mode 100644 index 0000000..ce68903 --- /dev/null +++ b/app/views/comments/create.js.erb~ @@ -0,0 +1,4 @@ +// Programa jQuery/Javascript +// -> sustituye la lista de visitas de un viaje en DOM +// -> HTML se genera en servidor con ERb +$('#comment').html("<%= j render @comment.site %>"); diff --git a/app/views/comments/edit.html.erb b/app/views/comments/edit.html.erb new file mode 100644 index 0000000..154e914 --- /dev/null +++ b/app/views/comments/edit.html.erb @@ -0,0 +1,27 @@ +

Editing comment

+ +<%= form_for(@comment) do |f| %> + <% if @comment.errors.any? %> +
+

<%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:

+ +
    + <% @comment.errors.full_messages.each do |msg| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.text_area :comment, :maxlength => 240, :rows => 6 %> +
+ <%= f.number_field :site_id, :value => @site.id, :hidden => true %> +
+ <%= f.submit %> +
+<% end %> + +
+ <%= link_to 'Back', site_path(@site) %> +
diff --git a/app/views/comments/edit.html.erb~ b/app/views/comments/edit.html.erb~ new file mode 100644 index 0000000..af18cc3 --- /dev/null +++ b/app/views/comments/edit.html.erb~ @@ -0,0 +1,6 @@ +

Editing site

+ +<%= render 'form' %> + +<%= link_to 'Show', @site %> | +<%= link_to 'Back', sites_path %> diff --git a/app/views/comments/index.html.erb b/app/views/comments/index.html.erb new file mode 100644 index 0000000..62cebaa --- /dev/null +++ b/app/views/comments/index.html.erb @@ -0,0 +1,14 @@ +

Comentarios de <%= @site.name %>

+ +
+ <%= render(@site) %> +
+ +<% if current_user %> +

Añada su comentario

+ <%= render 'form' %> +<% end %> + +
+ <%= link_to 'Back', sites_path %> +
\ No newline at end of file diff --git a/app/views/comments/index.html.erb~ b/app/views/comments/index.html.erb~ new file mode 100644 index 0000000..684f636 --- /dev/null +++ b/app/views/comments/index.html.erb~ @@ -0,0 +1,7 @@ +

Comentarios de <%= @site.name %>

+ +<%= render'comment' %> + +<%= render 'form' %> + +<%= link_to 'Back', sites_path %> diff --git a/app/views/comments/new.html.erb b/app/views/comments/new.html.erb new file mode 100644 index 0000000..88b9d58 --- /dev/null +++ b/app/views/comments/new.html.erb @@ -0,0 +1,28 @@ +

New comment

+ +<%= form_for(@comment) do |f| %> + <% if @comment.errors.any? %> +
+

<%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:

+ +
    + <% @comment.errors.full_messages.each do |msg| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + +

Añada su comentario

+
+ <%= f.text_area :comment, :maxlength => 240, :rows => 6 %> +
+ <%= f.number_field :site_id, :value => @site.id, :hidden => true %> +
+ <%= f.submit 'Nuevo comentario' %> +
+<% end %> + +
+ <%= link_to 'Back', site_path(@site) %> +
diff --git a/app/views/comments/new.html.erb~ b/app/views/comments/new.html.erb~ new file mode 100644 index 0000000..37340dc --- /dev/null +++ b/app/views/comments/new.html.erb~ @@ -0,0 +1,5 @@ +

New site

+ +<%= render 'form' %> + +<%= link_to 'Back', sites_path %> diff --git a/app/views/comments/show.html.erb b/app/views/comments/show.html.erb new file mode 100644 index 0000000..b6fc999 --- /dev/null +++ b/app/views/comments/show.html.erb @@ -0,0 +1,21 @@ +

+ Comment: + <%= @comment.comment %> +

+ +

+ User: + <%= @comment.user.name %> +

+ +

+ Site: + <%= @comment.site.name %> +

+ +
+ <% if @comment.user == current_user %> + <%= link_to 'Edit', edit_comment_path(@comment) %> | + <% end %> + <%= link_to 'Back', site_path(@comment.site) %> +
diff --git a/app/views/comments/show.html.erb~ b/app/views/comments/show.html.erb~ new file mode 100644 index 0000000..904b6d4 --- /dev/null +++ b/app/views/comments/show.html.erb~ @@ -0,0 +1,21 @@ +
+ +

<%= @site.type.name if @site.type %>

+ + <%= image_tag(@site.image_url, :class => 'site_image') %> + +

<%= @site.name %>

+ +

<%=sanitize @site.description %>

+ +

Autor: + <%= @site.user.name if @site.user %>

+ +
+ +

+ +<% if @site.user == current_user %> + <%= link_to 'Edit', edit_site_path(@site) %> | +<% end %> +<%= link_to 'Back', sites_path %> diff --git a/app/views/devise/_links.erb b/app/views/devise/_links.erb new file mode 100644 index 0000000..da22c88 --- /dev/null +++ b/app/views/devise/_links.erb @@ -0,0 +1,27 @@ +

+ <%- if controller_name != 'sessions' %> + <%= link_to "Sign in", new_session_path(resource_name) %>
+ <% end -%> + + <%- if devise_mapping.registerable? && controller_name != 'registrations' %> + <%= link_to "Sign up", new_registration_path(resource_name) %>
+ <% end -%> + + <%- if devise_mapping.recoverable? && controller_name != 'passwords' %> + <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+ <% end -%> + + <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> + <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
+ <% end -%> + + <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> + <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
+ <% end -%> + + <%- if devise_mapping.omniauthable? %> + <%- resource_class.omniauth_providers.each do |provider| %> + <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %>
+ <% end -%> + <% end -%> +
\ No newline at end of file diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb new file mode 100644 index 0000000..d7d0419 --- /dev/null +++ b/app/views/devise/confirmations/new.html.erb @@ -0,0 +1,12 @@ +

Resend confirmation instructions

+ +<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %> + <%= devise_error_messages! %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.submit "Resend confirmation instructions" %>
+<% end %> + +<%= render "links" %> \ No newline at end of file diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb new file mode 100644 index 0000000..6db9922 --- /dev/null +++ b/app/views/devise/mailer/confirmation_instructions.html.erb @@ -0,0 +1,5 @@ +

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..bef6fee --- /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..f210fb2 --- /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..ac4cc77 --- /dev/null +++ b/app/views/devise/passwords/edit.html.erb @@ -0,0 +1,16 @@ +

Change your password

+ +<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %> + <%= devise_error_messages! %> + <%= f.hidden_field :reset_password_token %> + +
<%= f.label :password, "New password" %>
+ <%= f.password_field :password %>
+ +
<%= f.label :password_confirmation, "Confirm new password" %>
+ <%= f.password_field :password_confirmation %>
+ +
<%= f.submit "Change my password" %>
+<% end %> + +<%= render "links" %> \ No newline at end of file diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb new file mode 100644 index 0000000..e84636a --- /dev/null +++ b/app/views/devise/passwords/new.html.erb @@ -0,0 +1,12 @@ +

Forgot your password?

+ +<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %> + <%= devise_error_messages! %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.submit "Send me reset password instructions" %>
+<% end %> + +<%= render "links" %> \ No newline at end of file diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb new file mode 100644 index 0000000..7e9f8e0 --- /dev/null +++ b/app/views/devise/registrations/edit.html.erb @@ -0,0 +1,30 @@ +

Edit <%= resource_name.to_s.humanize %>

+ +<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %> + <%= devise_error_messages! %> + +

<%= f.label :name %>
+ <%= f.text_field :name %>

+ +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.label :password %> (leave blank if you don't want to change it)
+ <%= f.password_field :password, :autocomplete => "off" %>
+ +
<%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+ +
<%= f.label :current_password %> (we need your current password to confirm your changes)
+ <%= f.password_field :current_password %>
+ +
<%= f.submit "Update" %>
+<% end %> + +

Cancel my account

+ +

Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.

+ +
+ <%= link_to "Back", :back %> +
\ No newline at end of file diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb new file mode 100644 index 0000000..8c9c8e7 --- /dev/null +++ b/app/views/devise/registrations/new.html.erb @@ -0,0 +1,21 @@ +

Sign up

+ +<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> + <%= devise_error_messages! %> + +

<%= f.label :name %>
+ <%= f.text_field :name %>

+ +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.label :password %>
+ <%= f.password_field :password %>
+ +
<%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+ +
<%= f.submit "Sign up" %>
+<% end %> + +<%= render "links" %> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb new file mode 100644 index 0000000..8f3ce23 --- /dev/null +++ b/app/views/devise/sessions/new.html.erb @@ -0,0 +1,17 @@ +

Sign in

+ +<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %> +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.label :password %>
+ <%= f.password_field :password %>
+ + <% if devise_mapping.rememberable? -%> +
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
+ <% end -%> + +
<%= f.submit "Sign in" %>
+<% end %> + +<%= render "links" %> \ No newline at end of file diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb new file mode 100644 index 0000000..7cdfd66 --- /dev/null +++ b/app/views/devise/unlocks/new.html.erb @@ -0,0 +1,12 @@ +

Resend unlock instructions

+ +<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %> + <%= devise_error_messages! %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.submit "Resend unlock instructions" %>
+<% end %> + +<%= render "links" %> \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1ed9716..9044507 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,33 +1,77 @@ - - - - Planet - <%= stylesheet_link_tag "application" %> - <%= javascript_include_tag "application" %> - <%= csrf_meta_tags %> - - - - - - -
-
- <%= link_to "Home", planet_index_path %>
- <%= link_to "Tipos", types_path %>
- <%= link_to "Sitios", sites_path %>
- <%= link_to "Contact", planet_contact_path %> -
-
- <%= yield %> -
-
- - \ No newline at end of file + + + + Planet + <%= stylesheet_link_tag "application" %> + <%= javascript_include_tag "application" %> + <%= csrf_meta_tags %> + + + + + + +
+ <% if current_user %> + <%= link_to current_user.name, edit_user_registration_path %> | + <%= link_to "Sign out", destroy_user_session_path, :method => :delete %> + <% else %> + <%= link_to "Sign in", new_user_session_path %> + <% end %> +
+ +
+
+ <%= link_to "Home", planet_index_path %>
+ <%= link_to "Tipos", types_path %>
+ <%= link_to "Sitios", sites_path %>
+
    + <% Type.all.each do |type| %> +
  • <%= link_to type.name, type_sites_path(type) %>
  • + <% end %> +
+ <%= link_to "Viajes", trips_path %>
+ <%= link_to "Contact", planet_contact_path %>
+ <%= link_to "Documentación", "/doc/app/index.html" %>
+ <%= link_to "Sign up", new_user_registration_path unless current_user %> +
+ +
+

<%= notice %>

<%= alert %>

+
+

+ <%= form_tag planet_search_path, :method => 'get' do %> + <%= text_field_tag :search, params[:search], id:'search' %> + <%= submit_tag "Search", :name => nil, id:'search_button' %> + <% end %> +
+ + + + <%= yield %> + + +
+
+ + diff --git a/app/views/layouts/application.html.erb~ b/app/views/layouts/application.html.erb~ new file mode 100644 index 0000000..d7f82b3 --- /dev/null +++ b/app/views/layouts/application.html.erb~ @@ -0,0 +1,79 @@ + + + + Planet + <%= stylesheet_link_tag "application" %> + <%= javascript_include_tag "application" %> + <%= csrf_meta_tags %> + + + + + + +
+ <% if current_user %> + <%= link_to current_user.name, + edit_user_registration_path %> | + <%= link_to "Sign out", destroy_user_session_path, :method => :delete %> + <% else %> + <%= link_to "Sign in", new_user_session_path %> + <% end %> +
+ +
+
+ <%= link_to "Home", planet_index_path %>
+ <%= link_to "Tipos", types_path %>
+ <%= link_to "Sitios", sites_path %>
+
    + <% Type.all.each do |type| %> +
  • <%= link_to type.name, type_sites_path(type) %>
  • + <% end %> +
+ <%= link_to "Viajes", trips_path %>
+ <%= link_to "Contact", planet_contact_path %>
+ <%= link_to "Documentación", root_path/doc/appindex.html %>
+ <%= link_to "Sign up", new_user_registration_path unless current_user %> + +
+
+ + +

<%= notice %>

<%= alert %>

+ <%= link_to('Index', planet_index_path) + "|" + link_to('Contact', planet_contact_path) + "|" + link_to('Ejemplo', planet_ejemplo_path)+ "|" + link_to('Autores', planet_author_path)+ "|" + link_to('Tipos', types_path) + "|" + link_to('Tipos_ordenados', ordered_index_types_path) %> + <%= yield %> + +

+ <%= link_to('Index', planet_index_path) + "|" + link_to('Contact', planet_contact_path) + "|" + link_to('Ejemplo', planet_ejemplo_path)+ "|" + link_to('Autores', planet_author_path)+ "|" + link_to('Tipos', types_path) + "|" + link_to('Tipos_ordenados', ordered_index_types_path) %> +

+
+
+ + diff --git a/app/views/layouts/application_mozilla.html.erb b/app/views/layouts/application_mozilla.html.erb new file mode 100644 index 0000000..8b0fa46 --- /dev/null +++ b/app/views/layouts/application_mozilla.html.erb @@ -0,0 +1,77 @@ + + + + Planet + <%= stylesheet_link_tag "application" %> + <%= javascript_include_tag "application" %> + <%= csrf_meta_tags %> + + + + + + +
+ <% if current_user %> + <%= link_to current_user.name, edit_user_registration_path %> | + <%= link_to "Sign out", destroy_user_session_path, :method => :delete %> + <% else %> + <%= link_to "Sign in", new_user_session_path %> + <% end %> +
+ +
+
+ <%= link_to "Home", planet_index_path %>
+ <%= link_to "Tipos", types_path %>
+ <%= link_to "Sitios", sites_path %>
+
    + <% Type.all.each do |type| %> +
  • <%= link_to type.name, type_sites_path(type) %>
  • + <% end %> +
+ <%= link_to "Viajes", trips_path %>
+ <%= link_to "Contact", planet_contact_path %>
+ <%= link_to "Documentación", "/doc/app/index.html" %>
+ <%= link_to "Sign up", new_user_registration_path unless current_user %> +
+ +
+

<%= notice %>

<%= alert %>

+
+

+ <%= form_tag planet_search_path, :method => 'get' do %> + <%= text_field_tag :search, params[:search], id:'search' %> + <%= submit_tag "Search", :name => nil, :disabled => true, id:'search_button' %> + <% end %> +
+ + + + <%= yield %> + + +
+
+ + \ No newline at end of file diff --git a/app/views/planet/author.html.erb b/app/views/planet/author.html.erb new file mode 100644 index 0000000..3eb7d6b --- /dev/null +++ b/app/views/planet/author.html.erb @@ -0,0 +1,32 @@ + + + Autores + + + +

+ Información sobre los creadores +

+ +

En esta página podrá encontrar varios datos sobre los creadores +

+ +

Alberto Moreno Díaz

+ <%= image_tag('alberto.jpg') %> +
    +
  • Dirección de correo: alberto.moreno.diaz@alumnos.upm.es
  • +
  • Dirección física: C/Sin nombre 7, 9ºB, Madrid
  • +
  • Breve currículum: estudiante de 4º curso de Ingeniería de Telecomunicación en la ETSIT.
  • +
+ +

Francisco José Gil García

+ <%= image_tag('francisco.jpg') %> +
    +
  • Dirección de correo: fj.gil@alumnos.upm.es
  • +
  • Dirección física: C/Con nombre 2, Bajo Derecha, Villatempujo de arriba
  • +
  • Breve currículum: a rellenar
  • +
+ +

Para cualquier duda o problema no dude en contactarnos.

+ + \ No newline at end of file diff --git a/app/views/planet/author.html.erb~ b/app/views/planet/author.html.erb~ new file mode 100644 index 0000000..53eca04 --- /dev/null +++ b/app/views/planet/author.html.erb~ @@ -0,0 +1,28 @@ + + +Autores + + +

+Información sobre los creadores +

+ +

En esta página podrá encontrar varios datos sobre los creadores +

+

Alberto Moreno Díaz

+<%= image_tag('alberto_contador.jpg') %> + +

Francisco José Gil García

+<%= image_tag('pizarro.jpg') %> +
    +
  • Dirección de correo: fj.gil@alumnos.upm.es
  • +
  • Dirección física: 555 Evergreen Terrace
  • +
  • Breve currículum: a rellenar también
  • +
+

Para cualquier duda o problema no dude en contactarnos.

+ + diff --git a/app/views/planet/index.html.erb b/app/views/planet/index.html.erb index bbee722..743d57a 100644 --- a/app/views/planet/index.html.erb +++ b/app/views/planet/index.html.erb @@ -1 +1 @@ -

Wecome to the Planet Travel Site

This site gathers information of touristic sites from all over the world and should help you to organize your trips and your holidays.

<%= image_tag('pedriza2-m.png') %>

Feel free to use it for your convenience and pleasure.

\ No newline at end of file +

Welcome to the Planet Travel Site

This site gathers information of touristic sites from all over the world and should help you to organize your trips and your holidays.

<%= image_tag('pedriza2-m.png') %>

Feel free to use it for your convenience and pleasure.

\ No newline at end of file diff --git a/app/views/planet/search.html.erb b/app/views/planet/search.html.erb new file mode 100644 index 0000000..22b9622 --- /dev/null +++ b/app/views/planet/search.html.erb @@ -0,0 +1,11 @@ +
+

Resultados en sitios

+ + <%= render 'sites/sites' %> +
+ +
+

Resultados en viajes

+ + <%= render 'trips/trips' %> +
diff --git a/app/views/planet/search.html.erb~ b/app/views/planet/search.html.erb~ new file mode 100644 index 0000000..677e130 --- /dev/null +++ b/app/views/planet/search.html.erb~ @@ -0,0 +1,32 @@ + + + Autores + + + +

+ Información sobre los creadores +

+ +

En esta página podrá encontrar varios datos sobre los creadores +

+ +

Alberto Moreno Díaz

+ <%= image_tag('alberto.jpg') %> +
    +
  • Dirección de correo: alberto.moreno.diaz@alumnos.upm.es
  • +
  • Dirección física: C/Sin nombre 7, 9ºB, Madrid
  • +
  • Breve currículum: estudiante de 4º curso de Ingeniería de Telecomunicación en la ETSIT.
  • +
+ +

Francisco José Gil García

+ <%= image_tag('francisco.jpg') %> +
    +
  • Dirección de correo: fj.gil@alumnos.upm.es
  • +
  • Dirección física: C/Con nombre 2, Bajo Derecha, Villatempujo de arriba
  • +
  • Breve currículum: a rellenar
  • +
+ +

Para cualquier duda o problema no dude en contactarnos.

+ + diff --git a/app/views/sites/_form.html.erb b/app/views/sites/_form.html.erb index abc9fec..9f27a0e 100644 --- a/app/views/sites/_form.html.erb +++ b/app/views/sites/_form.html.erb @@ -1,33 +1,45 @@ -<%= 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| %> -
  • <%= msg %>
  • - <% end %> -
-
- <% end %> - -
- <%= f.label :name %>
- <%= f.text_field :name %> -
-
- <%= f.label :description %>
- <%= f.text_area :description , :rows => 4 %> -
-
- <%= f.label :type_id %>
- <%= f.collection_select(:type_id, Type.find(:all, :order => :name), :id, :name) %> -
-
- <%= f.label :image_url %>
- <%= f.text_field :image_url %> -
-
- <%= f.submit %> -
-<% end %> +<%= 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| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
+
+ <%= f.label :description %>
+ <%= f.text_area :description , :rows => 4 %> +
+
+ <%= f.label :type_id %>
+ <%= f.collection_select(:type_id, Type.find(:all, :order => :name), :id, :name) %> +
+
+ <%= f.label :image %>
+ <%= f.file_field :image %> +
+
+ <%= f.label :latitud %>
+ <%= f.text_field :latitud, id:'latitud' %> +
+
+ <%= f.label :longitud %>
+ <%= f.text_field :longitud, id:'longitud' %> +
+
+ <%= f.label :zoom %>
+ <%= f.select(:zoom, Array.new(21, 0).fill{|i| [(i.to_s), i]}) %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/sites/_form.html.erb~ b/app/views/sites/_form.html.erb~ new file mode 100644 index 0000000..7fdb626 --- /dev/null +++ b/app/views/sites/_form.html.erb~ @@ -0,0 +1,45 @@ +<%= 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| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
+
+ <%= f.label :description %>
+ <%= f.text_area :description , :rows => 4 %> +
+
+ <%= f.label :type_id %>
+ <%= f.collection_select(:type_id, Type.find(:all, :order => :name), :id, :name) %> +
+
+ <%= f.label :image_url %>
+ <%= f.text_field :image_url %> +
+
+ <%= f.label :longitud %>
+ <%= f.text_field :longitud %> +
+
+ <%= f.label :latitud %>
+ <%= f.text_field :latitud %> +
+
+ <%= f.label :zoom %>
+ <%= f.text_field :zoom %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/sites/_newform.html.erb b/app/views/sites/_newform.html.erb new file mode 100644 index 0000000..4e3f9a9 --- /dev/null +++ b/app/views/sites/_newform.html.erb @@ -0,0 +1,24 @@ + + + + + + + + + <%= render 'form' %> + + diff --git a/app/views/sites/_newform.html.erb~ b/app/views/sites/_newform.html.erb~ new file mode 100644 index 0000000..8a6cd87 --- /dev/null +++ b/app/views/sites/_newform.html.erb~ @@ -0,0 +1,65 @@ + + + + + + + + + +<%= 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| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
+
+ <%= f.label :description %>
+ <%= f.text_area :description , :rows => 4 %> +
+
+ <%= f.label :type_id %>
+ <%= f.collection_select(:type_id, Type.find(:all, :order => :name), :id, :name) %> +
+
+ <%= f.label :image_url %>
+ <%= f.text_field :image_url %> +
+ <%= f.number_field :latitud, :value => @site.latitud, :hidden => true, :id => "latitud" %> + <%= f.number_field :longitud, :value => @site.longitud, :hidden => true, :id => "longitud" %> +
+ <%= f.label :zoom %>
+ <%= f.number_field :zoom, :value => 15 %> +
+
+ <%= f.submit %> +
+<% end %> + + diff --git a/app/views/sites/_newformantiguo.html.erb b/app/views/sites/_newformantiguo.html.erb new file mode 100644 index 0000000..374efc6 --- /dev/null +++ b/app/views/sites/_newformantiguo.html.erb @@ -0,0 +1,65 @@ + + + + + + + + + +<%= 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| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
+
+ <%= f.label :description %>
+ <%= f.text_area :description , :rows => 4 %> +
+
+ <%= f.label :type_id %>
+ <%= f.collection_select(:type_id, Type.find(:all, :order => :name), :id, :name) %> +
+
+ <%= f.label :image_url %>
+ <%= f.text_field :image_url %> +
+ <%= f.number_field :latitud, :value => @site.latitud, :hidden => true, :id => "latitud" %> + <%= f.number_field :longitud, :value => @site.longitud, :hidden => true, :id => "longitud" %> +
+ <%= f.label :zoom %>
+ <%= f.number_field :zoom, :value => 15 %> +
+
+ <%= f.submit %> +
+<% end %> + + diff --git a/app/views/sites/_site.html.erb b/app/views/sites/_site.html.erb new file mode 100644 index 0000000..d63cc53 --- /dev/null +++ b/app/views/sites/_site.html.erb @@ -0,0 +1,28 @@ +
+ + <% site.comments.each do |comment| %> + + + + + + + <% end %> +
+
+ <% if comment.user == current_user %> +
<%= link_to comment.user.name + ":", edit_user_registration_path %>
+ <% else %> +
<%= comment.user.name + ":" %>
+ <% end %> +
<%= strip_tags(comment.comment) %>
+
+
+ <% if comment.user == current_user %> + <%= link_to 'Edit', edit_comment_path(comment) %>
+ <%= link_to 'Destroy', comment, + :confirm => 'Are you sure?', + :method => :delete if comment.user == current_user %> + <% end %> +
+
\ No newline at end of file diff --git a/app/views/sites/_sites.html.erb b/app/views/sites/_sites.html.erb new file mode 100644 index 0000000..cc31b61 --- /dev/null +++ b/app/views/sites/_sites.html.erb @@ -0,0 +1,33 @@ +
+ + <% @sites.each do |site| %> + + + + + + + + <% end %> +
+ <%= link_to image_tag(site.image.url, :class => 'list_image'), site %> + +
+
<%= link_to site.name, site %>
+
<%= truncate(strip_tags(site.description), :length => 80) %>
+
+ Viajes: <%= site.trips.size %>
+ <% unless site.comments.empty? %> + <%= link_to 'Comentarios', site_comments_path(site) %> + <% end %> +
+
+ <%= 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 %> +
+
\ No newline at end of file diff --git a/app/views/sites/edit.html.erb b/app/views/sites/edit.html.erb index d46384f..ef68a5c 100644 --- a/app/views/sites/edit.html.erb +++ b/app/views/sites/edit.html.erb @@ -1,6 +1,8 @@ -

Editing site

- -<%= render 'form' %> - -<%= link_to 'Show', @site %> | -<%= link_to 'Back', sites_path %> +

Editing site

+ +<%= render 'form' %> + +
+ <%= link_to 'Show', @site %> | + <%= link_to 'Back', sites_path %> +
\ No newline at end of file diff --git a/app/views/sites/index.html.erb b/app/views/sites/index.html.erb index f1034b8..0fba005 100644 --- a/app/views/sites/index.html.erb +++ b/app/views/sites/index.html.erb @@ -1,34 +1,9 @@ -
-

Listing Sites

- - - <% @sites.each do |site| %> - - - - - - - - - <% end %> -
- <%= link_to image_tag(site.image_url, :class => 'list_image'), site %> - -
-
<%= link_to site.name, site %>
-
<%= truncate(strip_tags(site.description), - :length => 80) %>
-
-
- <%= link_to 'Show', site %>
- <%= link_to 'Edit', edit_site_path(site) %>
- <%= link_to 'Destroy', site, - :confirm => 'Are you sure?', - :method => :delete %> -
-
- -
- -<%= link_to 'New site', new_site_path %> \ No newline at end of file +
+

<%= @sites == Site.all ? "Todos los sitios" : Type.find(params[:type_id]).name %>

+ + <%= render 'sites' %> +
+ +
+ <%= link_to 'New site', new_site_path %> +
\ No newline at end of file diff --git a/app/views/sites/index.html.erb~ b/app/views/sites/index.html.erb~ new file mode 100644 index 0000000..9cac379 --- /dev/null +++ b/app/views/sites/index.html.erb~ @@ -0,0 +1,39 @@ +
+

<%= @sites == Site.all ? "Todos los sitios" : Type.find(params[:type_id]).name %>

+ + + <% @sites.each do |site| %> + + + + + + + + + <% end %> +
+ <%= link_to image_tag(site.image_url, :class => 'list_image'), site %> + +
+
<%= link_to site.name, site %>
+
<%= truncate(strip_tags(site.description), + :length => 80) %>
+ <% if site.comments %> + <%= link_to 'comentarios', comments_path(site) %>
+ <% end %> +
+
+ <%= 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 %> diff --git a/app/views/sites/new.html.erb b/app/views/sites/new.html.erb index 2988bdc..8524f27 100644 --- a/app/views/sites/new.html.erb +++ b/app/views/sites/new.html.erb @@ -1,5 +1,7 @@ -

New site

- -<%= render 'form' %> - -<%= link_to 'Back', sites_path %> +

New site

+ +<%= render 'newform' %> + +
+ <%= link_to 'Back', sites_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..37340dc --- /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 index 94dc17a..3a0ba19 100644 --- a/app/views/sites/show.html.erb +++ b/app/views/sites/show.html.erb @@ -1,15 +1,81 @@ -
- -

<%= @site.type.name if @site.type %>

- - <%= image_tag(@site.image_url, :class => 'site_image') %> - -

<%= @site.name %>

- -

<%=sanitize @site.description %>

- -
- -

-<%= link_to 'Edit', edit_site_path(@site) %> | -<%= link_to 'Back', sites_path %> + + + + + + + + + + +

+ +

<%= @site.type.name if @site.type %>

+ + <%= image_tag(@site.image.url, :class => 'site_image') %> + +

<%= @site.name %>

+

<%=sanitize @site.description %>

+

Autor: + <%= @site.user.name if @site.user %>

+

Latitud: + <%= @site.latitud %>

+

Longitud: + <%= @site.longitud %>

+

Zoom: + <%= @site.zoom %>

+ +
+

Viajes: <%= @site.trips.size %>

+
+ +
+

Visitas: <%= @site.visitas %>

+
+ +
+

Comentarios

+ <%= render(@site) %> +
+ + <% if current_user %> +

Añada su comentario

+ <%= render 'comments/form' %> + <% end %> + +

Posición geográfica

+ <% if (@site.latitud && @site.longitud && @site.zoom) %> + <% if (@site.latitud > -90 && @site.latitud < 90) %> +

+ <% else %> +

<%= @site.name %>: Latitud no válida (debe ser mayor que -90 y menor que 90) + <% end %> + <% else %> +

No se disponen de datos suficientes para mostrar la ubicación de <%= @site.name %>

+ <% end %> + +
+ <% if @site.user == current_user %> + <%= link_to 'Edit', edit_site_path(@site) %> | + <% end %> + <%= 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..825412c --- /dev/null +++ b/app/views/sites/show.html.erb~ @@ -0,0 +1,62 @@ + + + + + + + + +
+ +

<%= @site.type.name if @site.type %>

+ + <%= image_tag(@site.image_url, :class => 'site_image') %> + +

<%= @site.name %>

+ +

<%=sanitize @site.description %>

+ +

Autor: + <%= @site.user.name if @site.user %>

+

Latitud: + <%= @site.latitud %>

+

Longitud: + <%= @site.longitud %>

+ + <% unless @site.comments.empty? %> +

Comentarios:

+ <% @comments = @site.comments %> + <%= render(@comment) %> + <% end %> + + <%= render 'comments/form' %> + +
+ +
+

+<%= @site.image_url %> +<% if @site.user == current_user %> + <%= link_to 'Edit', edit_site_path(@site) %> | +<% end %> +<%= link_to 'Back', sites_path %> + + + diff --git a/app/views/sites/showantiguo.html.erb b/app/views/sites/showantiguo.html.erb new file mode 100644 index 0000000..415e1ef --- /dev/null +++ b/app/views/sites/showantiguo.html.erb @@ -0,0 +1,61 @@ + + + + + + + + + + +

+ +

<%= @site.type.name if @site.type %>

+ + <%= image_tag(@site.image_url, :class => 'site_image') %> + +

<%= @site.name %>

+ +

<%=sanitize @site.description %>

+ +

Autor: + <%= @site.user.name if @site.user %>

+

Latitud: + <%= @site.latitud %>

+

Longitud: + <%= @site.longitud %>

+ + <% unless @site.comments.empty? %> +

Comentarios:

+ <% @comments = @site.comments %> + <%= render(@comment) %> + <% end %> + + <%= render 'comments/form' %> + +
+ +

+

+<% if @site.user == current_user %> + <%= link_to 'Edit', edit_site_path(@site) %> | +<% end %> +<%= link_to 'Back', sites_path %> + + + diff --git a/app/views/trips/_form.html.erb b/app/views/trips/_form.html.erb new file mode 100644 index 0000000..34b1a6f --- /dev/null +++ b/app/views/trips/_form.html.erb @@ -0,0 +1,29 @@ +<%= form_for(@trip) do |f| %> + <% if @trip.errors.any? %> +
+

<%= pluralize(@trip.errors.count, "error") %> prohibited this trip from being saved:

+ +
    + <% @trip.errors.full_messages.each do |msg| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
+
+ <%= f.label :description %>
+ <%= f.text_area :description %> +
+
+ <%= f.label :date %>
+ <%= f.date_select :date %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/trips/_form.html.erb~ b/app/views/trips/_form.html.erb~ new file mode 100644 index 0000000..3f1ef01 --- /dev/null +++ b/app/views/trips/_form.html.erb~ @@ -0,0 +1,33 @@ +<%= form_for(@trip) do |f| %> + <% if @trip.errors.any? %> +
+

<%= pluralize(@trip.errors.count, "error") %> prohibited this trip from being saved:

+ +
    + <% @trip.errors.full_messages.each do |msg| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
+
+ <%= f.label :description %>
+ <%= f.text_area :description %> +
+
+ <%= f.label :date %>
+ <%= f.date_select :date %> +
+
+ <%= f.label :user_id %>
+ <%= f.number_field :user_id %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/trips/_trip.html.erb b/app/views/trips/_trip.html.erb new file mode 100644 index 0000000..f37f644 --- /dev/null +++ b/app/views/trips/_trip.html.erb @@ -0,0 +1,30 @@ +
+ + <% trip.visits.order(:hour).each do |visit| %> + + + + + + + + <% end %> +
+ <%= link_to image_tag(visit.site.image.url, :class => 'list_image'), visit.site %> + +
+
<%= visit.hour.to_s + 'h: ' %> + <%=link_to(visit.site.name, visit.site) %>
+
<%= truncate(strip_tags(visit.site.description), + :length => 80) %>
+
+
+ <%= link_to 'Show', visit.site %>
+ <%= link_to 'Destroy', visit, + :confirm => 'Are you sure?', + :method => :delete if trip.user == current_user %> + +
+
+ + diff --git a/app/views/trips/_trip.html.erb~ b/app/views/trips/_trip.html.erb~ new file mode 100644 index 0000000..779594c --- /dev/null +++ b/app/views/trips/_trip.html.erb~ @@ -0,0 +1,30 @@ +
+ + <% trip.visits.order(:hour).each do |visit| %> + + + + + + + + <% end %> +
+ <%= link_to image_tag(visit.site.image_url, :class => 'list_image'), visit.site %> + +
+
<%= visit.hour.to_s + 'h: ' %> + <%=link_to(visit.site.name, visit.site) %>
+
<%= truncate(strip_tags(visit.site.description), + :length => 80) %>
+
+
+ <%= link_to 'Show', visit.site %>
+ <%= link_to 'Destroy', visit, + :confirm => 'Are you sure?', + :method => :delete if trip.user == current_user %> + +
+
+ + diff --git a/app/views/trips/_trips.html.erb b/app/views/trips/_trips.html.erb new file mode 100644 index 0000000..08bc858 --- /dev/null +++ b/app/views/trips/_trips.html.erb @@ -0,0 +1,27 @@ +
+ + <% @trips.each do |trip| %> + + + + + + + <% end %> +
+
+
<%= link_to trip.name, trip_path(trip) %>
+
<%= truncate(strip_tags(trip.description), + :length => 80) + ', ' + trip.date.to_s %>
+
+
+ <%= 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, + :remote => true %> + <% end %> +
+
\ No newline at end of file diff --git a/app/views/trips/edit.html.erb b/app/views/trips/edit.html.erb new file mode 100644 index 0000000..90ad682 --- /dev/null +++ b/app/views/trips/edit.html.erb @@ -0,0 +1,8 @@ +

Editing trip

+ +<%= render 'form' %> + +
+ <%= link_to 'Show', @trip %> | + <%= link_to 'Back', trips_path %> +
\ No newline at end of file diff --git a/app/views/trips/index.html.erb b/app/views/trips/index.html.erb new file mode 100644 index 0000000..aa0df41 --- /dev/null +++ b/app/views/trips/index.html.erb @@ -0,0 +1 @@ +

Viajes

<%= render 'trips' %>
<%= link_to 'New Trip', new_trip_path %>
\ No newline at end of file diff --git a/app/views/trips/index.html.erb~ b/app/views/trips/index.html.erb~ new file mode 100644 index 0000000..61a904c --- /dev/null +++ b/app/views/trips/index.html.erb~ @@ -0,0 +1,28 @@ +
+

Viajes

+ + <% @trips.each do |trip| %> + + + + +<% end %> +
+
+
<%= link_to trip.name, trip_path(trip) %>
+
<%= truncate(strip_tags(trip.description), + :length => 80) + ', ' + trip.date.to_s %>
+
+
+ <%= link_to 'Show', trip %>
+ <% if site.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 %> + diff --git a/app/views/trips/new.html.erb b/app/views/trips/new.html.erb new file mode 100644 index 0000000..68b88f9 --- /dev/null +++ b/app/views/trips/new.html.erb @@ -0,0 +1,7 @@ +

New trip

+ +<%= render 'form' %> + +
+ <%= 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..2049b58 --- /dev/null +++ b/app/views/trips/show.html.erb @@ -0,0 +1,84 @@ + + + + + + + + +

Name: <%= @trip.name %>

+

Date: <%= @trip.date %>

+

Autor: <%= @trip.user.name if @trip.user %>

+

Description: <%= simple_format @trip.description %>

+ +
+

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 %> +
+ +

Posición geográfica

+ <% mapa = false %> + <% @trip.sites.each do |site| %> + <% if site.latitud && site.longitud %> + <% if site.latitud > -90 && site.latitud < 90 %> + <% mapa = true if !mapa %> + <% else %> +

<%= site.name %>: Latitud no válida (debe ser mayor que -90 y menor que 90) + <% end %> + <% else %> +

No se disponen de datos suficientes para mostrar la ubicación de <%= site.name %> + <% end %> + <% end %> + <% if mapa %> +

+ <% end %> + +

+ <% if @trip.user == current_user %> + <%= link_to 'Edit', edit_trip_path(@trip) %> | + <% end %> + <%= 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..b39b11d --- /dev/null +++ b/app/views/trips/show.html.erb~ @@ -0,0 +1,64 @@ + + + + + + + + +

Name: <%= @trip.name %>

Date: <%= @trip.date %>

+

Autor: <%= @trip.user.name if @trip.user %>

+

Description: <%= simple_format @trip.description %>

+ +
+

Sitios a visitar

+ <%= render(@trip) %> + <% if @trip.user == current_user %> + <%= form_for(@visit) 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 %> + + diff --git a/app/views/types/_form.html.erb b/app/views/types/_form.html.erb index 03447aa..02cc910 100644 --- a/app/views/types/_form.html.erb +++ b/app/views/types/_form.html.erb @@ -1,25 +1,25 @@ -<%= form_for(@type) do |f| %> - <% if @type.errors.any? %> -
-

<%= pluralize(@type.errors.count, "error") %> prohibited this type from being saved:

- -
    - <% @type.errors.full_messages.each do |msg| %> -
  • <%= msg %>
  • - <% end %> -
-
- <% end %> - -
- <%= f.label :name %>
- <%= f.text_field :name %> -
-
- <%= f.label :description %>
- <%= f.text_area :description %> -
-
- <%= f.submit %> -
-<% end %> +<%= form_for(@type) do |f| %> + <% if @type.errors.any? %> +
+

<%= pluralize(@type.errors.count, "error") %> prohibited this type from being saved:

+ +
    + <% @type.errors.full_messages.each do |msg| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
+
+ <%= f.label :description %>
+ <%= f.text_area :description, :rows => 4 %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/types/edit.html.erb b/app/views/types/edit.html.erb index fa73e65..3965ab7 100644 --- a/app/views/types/edit.html.erb +++ b/app/views/types/edit.html.erb @@ -1,6 +1,8 @@ -

Editing type

- -<%= render 'form' %> - -<%= link_to 'Show', @type %> | -<%= link_to 'Back', types_path %> +

Editing type

+ +<%= render 'form' %> + +
+ <%= link_to 'Show', @type %> | + <%= link_to 'Back', types_path %> +
\ No newline at end of file diff --git a/app/views/types/index.html.erb b/app/views/types/index.html.erb index e761359..d187b57 100644 --- a/app/views/types/index.html.erb +++ b/app/views/types/index.html.erb @@ -1,30 +1,30 @@ -
-

Listing Types

- - - <% @types.each do |type| %> - - - - - - - <% end %> -
-
-
<%= link_to type.name, type_sites_path(type) %>
-
<%= truncate(strip_tags(type.description), - :length => 80) %>
-
-
- <%= 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 %> +
+

Listing Types

+ + + <% @types.each do |type| %> + + + + + + + <% end %> +
+
+
<%= link_to type.name, type_sites_path(type) %>
+
<%= truncate(strip_tags(type.description), + :length => 80) %>
+
+
+ <%= 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 %> +
\ No newline at end of file diff --git a/app/views/types/index.html.erb~ b/app/views/types/index.html.erb~ new file mode 100644 index 0000000..5763e0e --- /dev/null +++ b/app/views/types/index.html.erb~ @@ -0,0 +1,31 @@ +
+

Listing Types

+ + + <% @types.each do |type| %> + + + + + + + <% end %> +
+
+
<%= link_to type.name, type_sites_path(type) %>
+
<%= truncate(strip_tags(type.description), + :length => 80) %>
+
+
+ <%= 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/index_ordenado.html.erb b/app/views/types/index_ordenado.html.erb new file mode 100644 index 0000000..26b15a3 --- /dev/null +++ b/app/views/types/index_ordenado.html.erb @@ -0,0 +1,26 @@ +

Listing types

+ + + + + + + + + + +<% @types.each do |type| %> + + + + + + + + +<% end %> +
NameDescription
<%= type.name %><%= type.description %><%= type.updated_at %><%= 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/new.html.erb b/app/views/types/new.html.erb index 0670946..4e138be 100644 --- a/app/views/types/new.html.erb +++ b/app/views/types/new.html.erb @@ -1,5 +1,7 @@ -

New type

- -<%= render 'form' %> - -<%= link_to 'Back', types_path %> +

New type

+ +<%= render 'form' %> + +
+ <%= link_to 'Back', types_path %> +
\ No newline at end of file diff --git a/app/views/types/ordered_index.html.erb b/app/views/types/ordered_index.html.erb new file mode 100644 index 0000000..d187b57 --- /dev/null +++ b/app/views/types/ordered_index.html.erb @@ -0,0 +1,30 @@ +
+

Listing Types

+ + + <% @types.each do |type| %> + + + + + + + <% end %> +
+
+
<%= link_to type.name, type_sites_path(type) %>
+
<%= truncate(strip_tags(type.description), + :length => 80) %>
+
+
+ <%= 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 %> +
\ No newline at end of file diff --git a/app/views/types/ordered_index.html.erb~ b/app/views/types/ordered_index.html.erb~ new file mode 100644 index 0000000..a090046 --- /dev/null +++ b/app/views/types/ordered_index.html.erb~ @@ -0,0 +1,26 @@ +

Listing types

+ + + + + + + + + + +<% @types.each do |type| %> + + + + + + + + +<% end %> +
NameDescription
<%= type.name %><%= type.description %><%= type.updated_at %><%= 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..7202c4f 100644 --- a/app/views/types/show.html.erb +++ b/app/views/types/show.html.erb @@ -1,15 +1,16 @@ -

<%= notice %>

- -

- Name: - <%= @type.name %> -

- -

- Description: - <%= @type.description %> -

- - -<%= link_to 'Edit', edit_type_path(@type) %> | -<%= link_to 'Back', types_path %> +

<%= notice %>

+ +

+ Name: + <%= @type.name %> +

+ +

+ Description: + <%= @type.description %> +

+ +
+ <%= link_to 'Edit', edit_type_path(@type) %> | + <%= link_to 'Back', types_path %> +
\ No newline at end of file diff --git a/app/views/types/show.html.erb~ b/app/views/types/show.html.erb~ new file mode 100644 index 0000000..4400a61 --- /dev/null +++ b/app/views/types/show.html.erb~ @@ -0,0 +1,19 @@ +

<%= notice %>

+ +

+ Name: + <%= @type.name %> +

+ +

+ Description: + <%= @type.description %> +

+ +

+ Updated at: + <%= @type.updated_at %> +

+ +<%= 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? %> +
+

<%= pluralize(@visit.errors.count, "error") %> prohibited this visit from being saved:

+ +
    + <% @visit.errors.full_messages.each do |msg| %> +
  • <%= msg %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= f.label :trip_id %>
+ <%= f.number_field :trip_id %> +
+
+ <%= f.label :site_id %>
+ <%= f.number_field :site_id %> +
+
+ <%= f.label :hour %>
+ <%= f.number_field :hour %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/visits/create.js.erb b/app/views/visits/create.js.erb new file mode 100644 index 0000000..4619ec3 --- /dev/null +++ b/app/views/visits/create.js.erb @@ -0,0 +1,5 @@ +// Programa jQuery/Javascript +// -> sustituye la lista de visitas de un viaje en DOM +// -> HTML se genera en servidor con ERb +$('#visit').html("<%= j render @visit.trip %>"); + diff --git a/app/views/visits/edit.html.erb b/app/views/visits/edit.html.erb new file mode 100644 index 0000000..f000918 --- /dev/null +++ b/app/views/visits/edit.html.erb @@ -0,0 +1,8 @@ +

Editing visit

+ +<%= render 'form' %> + +
+ <%= link_to 'Show', @visit %> | + <%= link_to 'Back', visits_path %> +
\ No newline at end of file diff --git a/app/views/visits/index.html.erb b/app/views/visits/index.html.erb new file mode 100644 index 0000000..6527e5c --- /dev/null +++ b/app/views/visits/index.html.erb @@ -0,0 +1,27 @@ +

Listing visits

+ + + + + + + + + + + +<% @visits.each do |visit| %> + + + + + + + + +<% end %> +
TripSiteHour
<%= 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 %> +
\ No newline at end of file diff --git a/app/views/visits/new.html.erb b/app/views/visits/new.html.erb new file mode 100644 index 0000000..0490ab9 --- /dev/null +++ b/app/views/visits/new.html.erb @@ -0,0 +1,7 @@ +

New visit

+ +<%= render 'form' %> + +
+ <%= link_to 'Back', visits_path %> +
\ No newline at end of file diff --git a/app/views/visits/show.html.erb b/app/views/visits/show.html.erb new file mode 100644 index 0000000..281cd84 --- /dev/null +++ b/app/views/visits/show.html.erb @@ -0,0 +1,21 @@ +

<%= notice %>

+ +

+ Trip: + <%= @visit.trip_id %> +

+ +

+ Site: + <%= @visit.site_id %> +

+ +

+ Hour: + <%= @visit.hour %> +

+ +
+ <%= link_to 'Edit', edit_visit_path(@visit) %> | + <%= link_to 'Back', visits_path %> +
\ No newline at end of file diff --git a/config.ru b/config.ru index 0a9abb6..1ec20e0 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,4 @@ -# This file is used by Rack-based servers to start the application. - -require ::File.expand_path('../config/environment', __FILE__) -run Planet::Application +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Planet::Application diff --git a/config/application.rb b/config/application.rb index 5ab23d7..5853707 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,59 +1,63 @@ -require File.expand_path('../boot', __FILE__) - -require 'rails/all' - -if defined?(Bundler) - # If you precompile assets before deploying to production, use this line - Bundler.require(*Rails.groups(:assets => %w(development test))) - # If you want your assets lazily compiled in production, use this line - # Bundler.require(:default, :assets, Rails.env) -end - -module Planet - class Application < Rails::Application - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - - # Custom directories with classes and modules you want to be autoloadable. - # config.autoload_paths += %W(#{config.root}/extras) - - # Only load the plugins named here, in the order given (default is alphabetical). - # :all can be used as a placeholder for all plugins not explicitly named. - # config.plugins = [ :exception_notification, :ssl_requirement, :all ] - - # Activate observers that should always be running. - # config.active_record.observers = :cacher, :garbage_collector, :forum_observer - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = 'Central Time (US & Canada)' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de - - # Configure the default encoding used in templates for Ruby 1.9. - config.encoding = "utf-8" - - # Configure sensitive parameters which will be filtered from the log file. - config.filter_parameters += [:password] - - # Use SQL instead of Active Record's schema dumper when creating the database. - # This is necessary if your schema can't be completely dumped by the schema dumper, - # like if you have constraints or database-specific column types - # config.active_record.schema_format = :sql - - # Enforce whitelist mode for mass assignment. - # This will create an empty whitelist of attributes available for mass-assignment for all models - # in your app. As such, your models will need to explicitly whitelist or blacklist accessible - # parameters by using an attr_accessible or attr_protected declaration. - # config.active_record.whitelist_attributes = true - - # Enable the asset pipeline - config.assets.enabled = true - - # Version of your assets, change this if you want to expire all your assets - config.assets.version = '1.0' - end -end +require File.expand_path('../boot', __FILE__) + +require 'rails/all' + +if defined?(Bundler) + # If you precompile assets before deploying to production, use this line + Bundler.require(*Rails.groups(:assets => %w(development test))) + # If you want your assets lazily compiled in production, use this line + # Bundler.require(:default, :assets, Rails.env) +end + +module Planet + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Custom directories with classes and modules you want to be autoloadable. + # config.autoload_paths += %W(#{config.root}/extras) + + # Only load the plugins named here, in the order given (default is alphabetical). + # :all can be used as a placeholder for all plugins not explicitly named. + # config.plugins = [ :exception_notification, :ssl_requirement, :all ] + + # Activate observers that should always be running. + # config.active_record.observers = :cacher, :garbage_collector, :forum_observer + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + + # Configure the default encoding used in templates for Ruby 1.9. + config.encoding = "utf-8" + + # Configure sensitive parameters which will be filtered from the log file. + config.filter_parameters += [:password] + + # Use SQL instead of Active Record's schema dumper when creating the database. + # This is necessary if your schema can't be completely dumped by the schema dumper, + # like if you have constraints or database-specific column types + # config.active_record.schema_format = :sql + + # Enforce whitelist mode for mass assignment. + # This will create an empty whitelist of attributes available for mass-assignment for all models + # in your app. As such, your models will need to explicitly whitelist or blacklist accessible + # parameters by using an attr_accessible or attr_protected declaration. + # config.active_record.whitelist_attributes = true + + # Enable the asset pipeline + config.assets.enabled = true + + # Version of your assets, change this if you want to expire all your assets + config.assets.version = '1.0' + + # Avoid problem when deploying to Heroku + # https://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar#troubleshooting + config.assets.initialize_on_precompile = false + end +end diff --git a/config/boot.rb b/config/boot.rb index 4489e58..dcefd6a 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,6 +1,6 @@ -require 'rubygems' - -# Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) - -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) +require 'rubygems' + +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) diff --git a/config/database.yml b/config/database.yml index 51a4dd4..c743cfa 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,25 +1,25 @@ -# SQLite version 3.x -# gem install sqlite3 -# -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem 'sqlite3' -development: - adapter: sqlite3 - database: db/development.sqlite3 - pool: 5 - timeout: 5000 - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - adapter: sqlite3 - database: db/test.sqlite3 - pool: 5 - timeout: 5000 - -production: - adapter: sqlite3 - database: db/production.sqlite3 - pool: 5 - timeout: 5000 +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +development: + adapter: sqlite3 + database: db/development.sqlite3 + pool: 5 + timeout: 5000 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + adapter: sqlite3 + database: db/test.sqlite3 + pool: 5 + timeout: 5000 + +production: + adapter: sqlite3 + database: db/production.sqlite3 + pool: 5 + timeout: 5000 diff --git a/config/environment.rb b/config/environment.rb index 722ad44..373b62d 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ -# Load the rails application -require File.expand_path('../application', __FILE__) - -# Initialize the rails application -Planet::Application.initialize! +# Load the rails application +require File.expand_path('../application', __FILE__) + +# Initialize the rails application +Planet::Application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 90121c9..6c79e5a 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,37 +1,40 @@ -Planet::Application.configure do - # Settings specified here will take precedence over those in config/application.rb - - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development - # since you don't have to restart the web server when you make code changes. - config.cache_classes = false - - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true - - # Show full error reports and disable caching - config.consider_all_requests_local = true - config.action_controller.perform_caching = false - - # Don't care if the mailer can't send - config.action_mailer.raise_delivery_errors = false - - # Print deprecation notices to the Rails logger - config.active_support.deprecation = :log - - # Only use best-standards-support built into browsers - config.action_dispatch.best_standards_support = :builtin - - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict - - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - config.active_record.auto_explain_threshold_in_seconds = 0.5 - - # Do not compress assets - config.assets.compress = false - - # Expands the lines which load the assets - config.assets.debug = true -end +Planet::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Log error messages when you accidentally call methods on nil. + config.whiny_nils = true + + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send + config.action_mailer.raise_delivery_errors = false + + # introducido para devise!!!! + config.action_mailer.default_url_options = { :host => 'localhost:3000' } + + # Print deprecation notices to the Rails logger + config.active_support.deprecation = :log + + # Only use best-standards-support built into browsers + config.action_dispatch.best_standards_support = :builtin + + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + config.active_record.auto_explain_threshold_in_seconds = 0.5 + + # Do not compress assets + config.assets.compress = false + + # Expands the lines which load the assets + config.assets.debug = true +end diff --git a/config/environments/production.rb b/config/environments/production.rb index 0f7140a..e369fcf 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,67 +1,67 @@ -Planet::Application.configure do - # Settings specified here will take precedence over those in config/application.rb - - # Code is not reloaded between requests - config.cache_classes = true - - # Full error reports are disabled and caching is turned on - config.consider_all_requests_local = false - config.action_controller.perform_caching = true - - # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = false - - # Compress JavaScripts and CSS - config.assets.compress = true - - # Don't fallback to assets pipeline if a precompiled asset is missed - config.assets.compile = false - - # Generate digests for assets URLs - config.assets.digest = true - - # Defaults to Rails.root.join("public/assets") - # config.assets.manifest = YOUR_PATH - - # Specifies the header that your server uses for sending files - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx - - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true - - # See everything in the log (default is :info) - # config.log_level = :debug - - # Prepend all log lines with the following tags - # config.log_tags = [ :subdomain, :uuid ] - - # Use a different logger for distributed setups - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) - - # Use a different cache store in production - # config.cache_store = :mem_cache_store - - # Enable serving of images, stylesheets, and JavaScripts from an asset server - # config.action_controller.asset_host = "http://assets.example.com" - - # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) - # config.assets.precompile += %w( search.js ) - - # Disable delivery errors, bad email addresses will be ignored - # config.action_mailer.raise_delivery_errors = false - - # Enable threaded mode - # config.threadsafe! - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found) - config.i18n.fallbacks = true - - # Send deprecation notices to registered listeners - config.active_support.deprecation = :notify - - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - # config.active_record.auto_explain_threshold_in_seconds = 0.5 -end +Planet::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # Code is not reloaded between requests + config.cache_classes = true + + # Full error reports are disabled and caching is turned on + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Disable Rails's static asset server (Apache or nginx will already do this) + config.serve_static_assets = false + + # Compress JavaScripts and CSS + config.assets.compress = true + + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = false + + # Generate digests for assets URLs + config.assets.digest = true + + # Defaults to Rails.root.join("public/assets") + # config.assets.manifest = YOUR_PATH + + # Specifies the header that your server uses for sending files + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # See everything in the log (default is :info) + # config.log_level = :debug + + # Prepend all log lines with the following tags + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # config.assets.precompile += %w( search.js ) + + # Disable delivery errors, bad email addresses will be ignored + # config.action_mailer.raise_delivery_errors = false + + # Enable threaded mode + # config.threadsafe! + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found) + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners + config.active_support.deprecation = :notify + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + # config.active_record.auto_explain_threshold_in_seconds = 0.5 +end diff --git a/config/environments/test.rb b/config/environments/test.rb index 08e07a5..7bb8ce3 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,37 +1,37 @@ -Planet::Application.configure do - # Settings specified here will take precedence over those in config/application.rb - - # The test environment is used exclusively to run your application's - # test suite. You never need to work with it otherwise. Remember that - # your test database is "scratch space" for the test suite and is wiped - # and recreated between test runs. Don't rely on the data there! - config.cache_classes = true - - # Configure static asset server for tests with Cache-Control for performance - config.serve_static_assets = true - config.static_cache_control = "public, max-age=3600" - - # Log error messages when you accidentally call methods on nil - config.whiny_nils = true - - # Show full error reports and disable caching - config.consider_all_requests_local = true - config.action_controller.perform_caching = false - - # Raise exceptions instead of rendering exception templates - config.action_dispatch.show_exceptions = false - - # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false - - # Tell Action Mailer not to deliver emails to the real world. - # The :test delivery method accumulates sent emails in the - # ActionMailer::Base.deliveries array. - config.action_mailer.delivery_method = :test - - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict - - # Print deprecation notices to the stderr - config.active_support.deprecation = :stderr -end +Planet::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Configure static asset server for tests with Cache-Control for performance + config.serve_static_assets = true + config.static_cache_control = "public, max-age=3600" + + # Log error messages when you accidentally call methods on nil + config.whiny_nils = true + + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict + + # Print deprecation notices to the stderr + config.active_support.deprecation = :stderr +end diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index 59385cd..803738d 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,7 +1,7 @@ -# Be sure to restart your server when you modify this file. - -# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. -# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } - -# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. -# Rails.backtrace_cleaner.remove_silencers! +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb new file mode 100644 index 0000000..2cb5e2a --- /dev/null +++ b/config/initializers/devise.rb @@ -0,0 +1,223 @@ +# Use this hook to configure devise mailer, warden hooks and so forth. +# Many of these configuration options can be set straight in your model. +Devise.setup do |config| + # ==> Mailer Configuration + # Configure the e-mail address which will be shown in Devise::Mailer, + # note that it will be overwritten if you use your own mailer class with default "from" parameter. + config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com" + + # Configure the class responsible to send e-mails. + # config.mailer = "Devise::Mailer" + + # Automatically apply schema changes in tableless databases + config.apply_schema = false + + # ==> ORM configuration + # Load and configure the ORM. Supports :active_record (default) and + # :mongoid (bson_ext recommended) by default. Other ORMs may be + # available as additional gems. + require 'devise/orm/active_record' + + # ==> Configuration for any authentication mechanism + # Configure which keys are used when authenticating a user. The default is + # just :email. You can configure it to use [:username, :subdomain], so for + # authenticating a user, both parameters are required. Remember that those + # parameters are used only when authenticating and not when retrieving from + # session. If you need permissions, you should implement that in a before filter. + # You can also supply a hash where the value is a boolean determining whether + # or not authentication should be aborted when the value is not present. + # config.authentication_keys = [ :email ] + + # Configure parameters from the request object used for authentication. Each entry + # given should be a request method and it will automatically be passed to the + # find_for_authentication method and considered in your model lookup. For instance, + # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. + # The same considerations mentioned for authentication_keys also apply to request_keys. + # config.request_keys = [] + + # Configure which authentication keys should be case-insensitive. + # These keys will be downcased upon creating or modifying a user and when used + # to authenticate or find a user. Default is :email. + config.case_insensitive_keys = [ :email ] + + # Configure which authentication keys should have whitespace stripped. + # These keys will have whitespace before and after removed upon creating or + # modifying a user and when used to authenticate or find a user. Default is :email. + config.strip_whitespace_keys = [ :email ] + + # Tell if authentication through request.params is enabled. True by default. + # It can be set to an array that will enable params authentication only for the + # given strategies, for example, `config.params_authenticatable = [:database]` will + # enable it only for database (email + password) authentication. + # config.params_authenticatable = true + + # Tell if authentication through HTTP Basic Auth is enabled. False by default. + # It can be set to an array that will enable http authentication only for the + # given strategies, for example, `config.http_authenticatable = [:token]` will + # enable it only for token authentication. + # config.http_authenticatable = false + + # If http headers should be returned for AJAX requests. True by default. + # config.http_authenticatable_on_xhr = true + + # The realm used in Http Basic Authentication. "Application" by default. + # config.http_authentication_realm = "Application" + + # It will change confirmation, password recovery and other workflows + # to behave the same regardless if the e-mail provided was right or wrong. + # Does not affect registerable. + # config.paranoid = true + + # By default Devise will store the user in session. You can skip storage for + # :http_auth and :token_auth by adding those symbols to the array below. + # Notice that if you are skipping storage for all authentication paths, you + # may want to disable generating routes to Devise's sessions controller by + # passing :skip => :sessions to `devise_for` in your config/routes.rb + config.skip_session_storage = [:http_auth] + + # ==> Configuration for :database_authenticatable + # For bcrypt, this is the cost for hashing the password and defaults to 10. If + # using other encryptors, it sets how many times you want the password re-encrypted. + # + # Limiting the stretches to just one in testing will increase the performance of + # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use + # a value less than 10 in other environments. + config.stretches = Rails.env.test? ? 1 : 10 + + # Setup a pepper to generate the encrypted password. + # config.pepper = "f807173825cac6c9c837bda6b02a30347a55bf933bb79161023a13d6827452aca8150a7940b27a4abf741e0159050a7b80787f789373c4a8b4475e1b2b3a47f6" + + # ==> Configuration for :confirmable + # A period that the user is allowed to access the website even without + # confirming his account. For instance, if set to 2.days, the user will be + # able to access the website for two days without confirming his account, + # access will be blocked just in the third day. Default is 0.days, meaning + # the user cannot access the website without confirming his account. + # config.allow_unconfirmed_access_for = 2.days + + # If true, requires any email changes to be confirmed (exctly the same way as + # initial account confirmation) to be applied. Requires additional unconfirmed_email + # db field (see migrations). Until confirmed new email is stored in + # unconfirmed email column, and copied to email column on successful confirmation. + config.reconfirmable = true + + # Defines which key will be used when confirming an account + # config.confirmation_keys = [ :email ] + + # ==> Configuration for :rememberable + # The time the user will be remembered without asking for credentials again. + # config.remember_for = 2.weeks + + # If true, extends the user's remember period when remembered via cookie. + # config.extend_remember_period = false + + # If true, uses the password salt as remember token. This should be turned + # to false if you are not using database authenticatable. + config.use_salt_as_remember_token = true + + # Options to be passed to the created cookie. For instance, you can set + # :secure => true in order to force SSL only cookies. + # config.cookie_options = {} + + # ==> Configuration for :validatable + # Range for password length. Default is 6..128. + # config.password_length = 6..128 + + # Email regex used to validate email formats. It simply asserts that + # an one (and only one) @ exists in the given string. This is mainly + # to give user feedback and not to assert the e-mail validity. + # config.email_regexp = /\A[^@]+@[^@]+\z/ + + # ==> Configuration for :timeoutable + # The time you want to timeout the user session without activity. After this + # time the user will be asked for credentials again. Default is 30 minutes. + # config.timeout_in = 30.minutes + + # ==> Configuration for :lockable + # Defines which strategy will be used to lock an account. + # :failed_attempts = Locks an account after a number of failed attempts to sign in. + # :none = No lock strategy. You should handle locking by yourself. + # config.lock_strategy = :failed_attempts + + # Defines which key will be used when locking and unlocking an account + # config.unlock_keys = [ :email ] + + # Defines which strategy will be used to unlock an account. + # :email = Sends an unlock link to the user email + # :time = Re-enables login after a certain amount of time (see :unlock_in below) + # :both = Enables both strategies + # :none = No unlock strategy. You should handle unlocking by yourself. + # config.unlock_strategy = :both + + # Number of authentication tries before locking an account if lock_strategy + # is failed attempts. + # config.maximum_attempts = 20 + + # Time interval to unlock the account if :time is enabled as unlock_strategy. + # config.unlock_in = 1.hour + + # ==> Configuration for :recoverable + # + # Defines which key will be used when recovering the password for an account + # config.reset_password_keys = [ :email ] + + # Time interval you can reset your password with a reset password key. + # Don't put a too small interval or your users won't have the time to + # change their passwords. + config.reset_password_within = 6.hours + + # ==> Configuration for :encryptable + # Allow you to use another encryption algorithm besides bcrypt (default). You can use + # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, + # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) + # and :restful_authentication_sha1 (then you should set stretches to 10, and copy + # REST_AUTH_SITE_KEY to pepper) + # config.encryptor = :sha512 + + # ==> Configuration for :token_authenticatable + # Defines name of the authentication token params key + # config.token_authentication_key = :auth_token + + # ==> Scopes configuration + # Turn scoped views on. Before rendering "sessions/new", it will first check for + # "users/sessions/new". It's turned off by default because it's slower if you + # are using only default views. + # config.scoped_views = false + + # Configure the default scope given to Warden. By default it's the first + # devise role declared in your routes (usually :user). + # config.default_scope = :user + + # Configure sign_out behavior. + # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope). + # The default is true, which means any logout action will sign out all active scopes. + # config.sign_out_all_scopes = true + + # ==> Navigation configuration + # Lists the formats that should be treated as navigational. Formats like + # :html, should redirect to the sign in page when the user does not have + # access, but formats like :xml or :json, should return 401. + # + # If you have any extra navigational formats, like :iphone or :mobile, you + # should add them to the navigational formats lists. + # + # The "*/*" below is required to match Internet Explorer requests. + # config.navigational_formats = ["*/*", :html] + + # The default HTTP method used to sign out a resource. Default is :delete. + config.sign_out_via = :delete + + # ==> OmniAuth + # Add a new OmniAuth provider. Check the wiki for more information on setting + # up on your models and hooks. + # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo' + + # ==> Warden configuration + # If you want to use other strategies, that are not supported by Devise, or + # change the failure app, you can configure them inside the config.warden block. + # + # config.warden do |manager| + # manager.intercept_401 = false + # manager.default_strategies(:scope => :user).unshift :some_external_strategy + # end +end diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 5d8d9be..4b0d15e 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,15 +1,15 @@ -# Be sure to restart your server when you modify this file. - -# Add new inflection rules using the following format -# (all these examples are active by default): -# ActiveSupport::Inflector.inflections do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' -# inflect.uncountable %w( fish sheep ) -# end -# -# These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections do |inflect| -# inflect.acronym 'RESTful' -# end +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format +# (all these examples are active by default): +# ActiveSupport::Inflector.inflections do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end +# +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 72aca7e..9b5f1a4 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,5 +1,5 @@ -# Be sure to restart your server when you modify this file. - -# Add new mime types for use in respond_to blocks: -# Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf +# Mime::Type.register_alias "text/html", :iphone diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index 2a0abc5..d0c9d53 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -1,7 +1,7 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -Planet::Application.config.secret_token = '1d0b0986958355469c26d5d36d0531ad5dccaa0483eefce0085cc8d90ae919113f57fc251d0a77dbcbe194736ae1f33a77fd54e95f4c72eb4851fdb4749f2b4a' +# Be sure to restart your server when you modify this file. + +# Your secret key for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +Planet::Application.config.secret_token = '1d0b0986958355469c26d5d36d0531ad5dccaa0483eefce0085cc8d90ae919113f57fc251d0a77dbcbe194736ae1f33a77fd54e95f4c72eb4851fdb4749f2b4a' diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 697d0c8..b29f254 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,8 +1,8 @@ -# Be sure to restart your server when you modify this file. - -Planet::Application.config.session_store :cookie_store, key: '_planet_session' - -# Use the database for sessions instead of the cookie-based default, -# which shouldn't be used to store highly confidential information -# (create the session table with "rails generate session_migration") -# Planet::Application.config.session_store :active_record_store +# Be sure to restart your server when you modify this file. + +Planet::Application.config.session_store :cookie_store, key: '_planet_session' + +# Use the database for sessions instead of the cookie-based default, +# which shouldn't be used to store highly confidential information +# (create the session table with "rails generate session_migration") +# Planet::Application.config.session_store :active_record_store diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 999df20..f51d76e 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -1,14 +1,14 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains settings for ActionController::ParamsWrapper which -# is enabled by default. - -# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. -ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [:json] -end - -# Disable root element in JSON by default. -ActiveSupport.on_load(:active_record) do - self.include_root_in_json = false -end +# Be sure to restart your server when you modify this file. +# +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# Disable root element in JSON by default. +ActiveSupport.on_load(:active_record) do + self.include_root_in_json = false +end diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml new file mode 100644 index 0000000..6051979 --- /dev/null +++ b/config/locales/devise.en.yml @@ -0,0 +1,57 @@ +# Additional translations at https://github.com/plataformatec/devise/wiki/I18n + +en: + errors: + messages: + expired: "has expired, please request a new one" + not_found: "not found" + already_confirmed: "was already confirmed, please try signing in" + not_locked: "was not locked" + not_saved: + one: "1 error prohibited this %{resource} from being saved:" + other: "%{count} errors prohibited this %{resource} from being saved:" + + devise: + failure: + already_authenticated: 'You are already signed in.' + unauthenticated: 'You need to sign in or sign up before continuing.' + unconfirmed: 'You have to confirm your account before continuing.' + locked: 'Your account is locked.' + invalid: 'Invalid email or password.' + invalid_token: 'Invalid authentication token.' + timeout: 'Your session expired, please sign in again to continue.' + inactive: 'Your account was not activated yet.' + sessions: + signed_in: 'Signed in successfully.' + signed_out: 'Signed out successfully.' + passwords: + send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.' + updated: 'Your password was changed successfully. You are now signed in.' + updated_not_active: 'Your password was changed successfully.' + send_paranoid_instructions: "If your e-mail exists on our database, you will receive a password recovery link on your e-mail" + confirmations: + send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.' + send_paranoid_instructions: 'If your e-mail exists on our database, you will receive an email with instructions about how to confirm your account in a few minutes.' + confirmed: 'Your account was successfully confirmed. You are now signed in.' + registrations: + signed_up: 'Welcome! You have signed up successfully.' + signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.' + signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.' + signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.' + updated: 'You updated your account successfully.' + update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address." + destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.' + unlocks: + send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.' + unlocked: 'Your account has been unlocked successfully. Please sign in to continue.' + send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.' + omniauth_callbacks: + success: 'Successfully authorized from %{kind} account.' + failure: 'Could not authorize you from %{kind} because "%{reason}".' + mailer: + confirmation_instructions: + subject: 'Confirmation instructions' + reset_password_instructions: + subject: 'Reset password instructions' + unlock_instructions: + subject: 'Unlock Instructions' diff --git a/config/locales/en.yml b/config/locales/en.yml index 179c14c..54d9327 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,5 +1,5 @@ -# Sample localization file for English. Add more files in this directory for other locales. -# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. - -en: - hello: "Hello world" +# Sample localization file for English. Add more files in this directory for other locales. +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. + +en: + hello: "Hello world" diff --git a/config/routes.rb b/config/routes.rb index 716dc7e..b841de4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,72 +1,88 @@ -Planet::Application.routes.draw do - resources :sites - - resources :types do # Rutas anidadas /types/id/sites..., - resources :sites, :only => [ :index ] # Restringe a acción “index” - end - - get "planet/index" - - get "planet/contact" - - get "planet/ejemplo" - - # The priority is based upon order of creation: - # first created -> highest priority. - - # Sample of regular route: - # match 'products/:id' => 'catalog#view' - # Keep in mind you can assign values other than :controller and :action - - # Sample of named route: - # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase - # This route can be invoked with purchase_url(:id => product.id) - - # Sample resource route (maps HTTP verbs to controller actions automatically): - # resources :products - - # Sample resource route with options: - # resources :products do - # member do - # get 'short' - # post 'toggle' - # end - # - # collection do - # get 'sold' - # end - # end - - # Sample resource route with sub-resources: - # resources :products do - # resources :comments, :sales - # resource :seller - # end - - # Sample resource route with more complex sub-resources - # resources :products do - # resources :comments - # resources :sales do - # get 'recent', :on => :collection - # end - # end - - # Sample resource route within a namespace: - # namespace :admin do - # # Directs /admin/products/* to Admin::ProductsController - # # (app/controllers/admin/products_controller.rb) - # resources :products - # end - - # You can have the root of your site routed with "root" - # just remember to delete public/index.html. - # root :to => 'welcome#index' - - root :to => "planet#index" - - # See how all your routes lay out with "rake routes" - - # This is a legacy wild controller route that's not recommended for RESTful applications. - # Note: This route will make all actions in every controller accessible via GET requests. - # match ':controller(/:action(/:id(.:format)))' -end +Planet::Application.routes.draw do + + resources :visits + + resources :trips + + resources :comments, :except => [ :index, :new ] + + devise_for :users + + resources :sites do + resources :comments, :only => [ :index, :new ] + end + + resources :types do + get 'ordered_index', :on => :collection + resources :sites, :only => [ :index ] # Rutas anidadas /types/id/sites. Restringe a acción “index” + end + + get "planet/index" + + get "planet/contact" + + get "planet/ejemplo" + + get "planet/author" + + get "planet/search" + + # The priority is based upon order of creation: + # first created -> highest priority. + + # Sample of regular route: + # match 'products/:id' => 'catalog#view' + # Keep in mind you can assign values other than :controller and :action + + # Sample of named route: + # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase + # This route can be invoked with purchase_url(:id => product.id) + + # Sample resource route (maps HTTP verbs to controller actions automatically): + # resources :products + + # Sample resource route with options: + # resources :products do + # member do + # get 'short' + # post 'toggle' + # end + # + # collection do + # get 'sold' + # end + # end + + # Sample resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller + # end + + # Sample resource route with more complex sub-resources + # resources :products do + # resources :comments + # resources :sales do + # get 'recent', :on => :collection + # end + # end + + # Sample resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # resources :products + # end + + # You can have the root of your site routed with "root" + # just remember to delete public/index.html. + # root :to => 'welcome#index' + + root :to => "planet#index" + + # See how all your routes lay out with "rake routes" + + # This is a legacy wild controller route that's not recommended for RESTful applications. + # Note: This route will make all actions in every controller accessible via GET requests. + # match ':controller(/:action(/:id(.:format)))' +end diff --git a/config/routes.rb~ b/config/routes.rb~ new file mode 100644 index 0000000..f587c30 --- /dev/null +++ b/config/routes.rb~ @@ -0,0 +1,86 @@ +Planet::Application.routes.draw do + + resources :visits + + resources :trips + + resources :comments, :except => [ :new, :index, :show ] + + devise_for :users + + resources :sites do + resources :comments, :only => [ :index ] + end + + resources :types do + get 'ordered_index', :on => :collection + resources :sites, :only => [ :index ] # Rutas anidadas /types/id/sites. Restringe a acción “index” + end + + get "planet/index" + + get "planet/contact" + + get "planet/ejemplo" + + get "planet/author" + + # The priority is based upon order of creation: + # first created -> highest priority. + + # Sample of regular route: + # match 'products/:id' => 'catalog#view' + # Keep in mind you can assign values other than :controller and :action + + # Sample of named route: + # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase + # This route can be invoked with purchase_url(:id => product.id) + + # Sample resource route (maps HTTP verbs to controller actions automatically): + # resources :products + + # Sample resource route with options: + # resources :products do + # member do + # get 'short' + # post 'toggle' + # end + # + # collection do + # get 'sold' + # end + # end + + # Sample resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller + # end + + # Sample resource route with more complex sub-resources + # resources :products do + # resources :comments + # resources :sales do + # get 'recent', :on => :collection + # end + # end + + # Sample resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # resources :products + # end + + # You can have the root of your site routed with "root" + # just remember to delete public/index.html. + # root :to => 'welcome#index' + + root :to => "planet#index" + + # See how all your routes lay out with "rake routes" + + # This is a legacy wild controller route that's not recommended for RESTful applications. + # Note: This route will make all actions in every controller accessible via GET requests. + # match ':controller(/:action(/:id(.:format)))' +end diff --git a/db/migrate/20120317231537_create_types.rb b/db/migrate/20120317231537_create_types.rb index fb4b514..c398988 100644 --- a/db/migrate/20120317231537_create_types.rb +++ b/db/migrate/20120317231537_create_types.rb @@ -1,10 +1,10 @@ -class CreateTypes < ActiveRecord::Migration - def change - create_table :types do |t| - t.string :name - t.text :description - - t.timestamps - end - end -end +class CreateTypes < ActiveRecord::Migration + def change + create_table :types do |t| + t.string :name + t.text :description + + t.timestamps + end + end +end diff --git a/db/migrate/20120320100145_create_sites.rb b/db/migrate/20120320100145_create_sites.rb index 823209a..c7da1e7 100644 --- a/db/migrate/20120320100145_create_sites.rb +++ b/db/migrate/20120320100145_create_sites.rb @@ -1,12 +1,11 @@ -class CreateSites < ActiveRecord::Migration - def change - create_table :sites do |t| - t.string :name - t.text :description - t.integer :type_id - t.string :image_url - - t.timestamps - end - end -end +class CreateSites < ActiveRecord::Migration + def change + create_table :sites do |t| + t.string :name + t.text :description + t.integer :type_id + t.string :image_url + t.timestamps + end + end +end diff --git a/db/migrate/20120320100145_create_sites.rb~ b/db/migrate/20120320100145_create_sites.rb~ new file mode 100644 index 0000000..9f009f1 --- /dev/null +++ b/db/migrate/20120320100145_create_sites.rb~ @@ -0,0 +1,14 @@ +class CreateSites < ActiveRecord::Migration + def change + create_table :sites do |t| + t.string :name + t.text :description + t.integer :type_id + t.string :image_url + t.float :longitud + t.float :latitud + t.integer :zoom + t.timestamps + end + end +end diff --git a/db/migrate/20120328230302_devise_create_users.rb b/db/migrate/20120328230302_devise_create_users.rb new file mode 100644 index 0000000..15ea6d7 --- /dev/null +++ b/db/migrate/20120328230302_devise_create_users.rb @@ -0,0 +1,49 @@ +class DeviseCreateUsers < ActiveRecord::Migration + def change + create_table(:users) do |t| + ## Database authenticatable + t.string :email, :null => false, :default => "" + t.string :encrypted_password, :null => false, :default => "" + + ## Recoverable + t.string :reset_password_token + t.datetime :reset_password_sent_at + + ## Rememberable + t.datetime :remember_created_at + + ## Trackable + t.integer :sign_in_count, :default => 0 + t.datetime :current_sign_in_at + t.datetime :last_sign_in_at + t.string :current_sign_in_ip + t.string :last_sign_in_ip + + ## Encryptable + # t.string :password_salt + + ## Confirmable + # t.string :confirmation_token + # t.datetime :confirmed_at + # t.datetime :confirmation_sent_at + # t.string :unconfirmed_email # Only if using reconfirmable + + ## Lockable + # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts + # t.string :unlock_token # Only if unlock strategy is :email or :both + # t.datetime :locked_at + + ## Token authenticatable + # t.string :authentication_token + + + t.timestamps + end + + add_index :users, :email, :unique => true + add_index :users, :reset_password_token, :unique => true + # add_index :users, :confirmation_token, :unique => true + # add_index :users, :unlock_token, :unique => true + # add_index :users, :authentication_token, :unique => true + end +end diff --git a/db/migrate/20120329060322_user_name.rb b/db/migrate/20120329060322_user_name.rb new file mode 100644 index 0000000..6ec2859 --- /dev/null +++ b/db/migrate/20120329060322_user_name.rb @@ -0,0 +1,13 @@ +class UserName < ActiveRecord::Migration + def up + change_table :users do |t| # añade la columna name a la tabla sites + t.column :name, :string + end + end + + def down + change_table :users do |t| + t.remove :name + end + end +end diff --git a/db/migrate/20120329080433_user_sites.rb b/db/migrate/20120329080433_user_sites.rb new file mode 100644 index 0000000..5831683 --- /dev/null +++ b/db/migrate/20120329080433_user_sites.rb @@ -0,0 +1,15 @@ +class UserSites < ActiveRecord::Migration + def up + change_table :sites do |t| # añade la columna user_id a la tabla sites + t.column :user_id, :integer + + end + end + + def down + change_table :sites do |t| + t.remove :user_id + + end + end +end diff --git a/db/migrate/20120329080433_user_sites.rb~ b/db/migrate/20120329080433_user_sites.rb~ new file mode 100644 index 0000000..6ac9682 --- /dev/null +++ b/db/migrate/20120329080433_user_sites.rb~ @@ -0,0 +1,19 @@ +class UserSites < ActiveRecord::Migration + def up + change_table :sites do |t| # añade la columna user_id a la tabla sites + t.column :user_id, :integer + t.column :longitud, :float + t.column :latitud, :float + t.column :zoom, :integer + end + end + + def down + change_table :sites do |t| + t.remove :user_id + t.remove :longitud + t.remove :latitud + t.remove :zoom + end + end +end diff --git a/db/migrate/20120410171102_create_comments.rb b/db/migrate/20120410171102_create_comments.rb new file mode 100644 index 0000000..36d0b14 --- /dev/null +++ b/db/migrate/20120410171102_create_comments.rb @@ -0,0 +1,11 @@ +class CreateComments < ActiveRecord::Migration + def change + create_table :comments do |t| + t.string :comment + t.integer :user_id + t.integer :site_id + + t.timestamps + end + end +end diff --git a/db/migrate/20120410202832_create_comments.rb b/db/migrate/20120410202832_create_comments.rb new file mode 100644 index 0000000..36d0b14 --- /dev/null +++ b/db/migrate/20120410202832_create_comments.rb @@ -0,0 +1,11 @@ +class CreateComments < ActiveRecord::Migration + def change + create_table :comments do |t| + t.string :comment + t.integer :user_id + t.integer :site_id + + t.timestamps + end + end +end diff --git a/db/migrate/20120411095828_add_paperclip_to_sites.rb b/db/migrate/20120411095828_add_paperclip_to_sites.rb new file mode 100644 index 0000000..3139184 --- /dev/null +++ b/db/migrate/20120411095828_add_paperclip_to_sites.rb @@ -0,0 +1,19 @@ +class AddPaperclipToSites < ActiveRecord::Migration + def up + change_table :sites do |t| + t.column :image_file_name, :string + t.column :image_content_type, :string + t.column :image_file_size, :string + t.column :image_updated_at, :datetime + end + end + + def down + change_table :sites do |t| + t.remove :image_file_name, :string + t.remove :image_content_type, :string + t.remove :image_file_size, :string + t.remove :image_updated_at, :datetime + end + end +end diff --git a/db/migrate/20120411160519_site_visitas.rb b/db/migrate/20120411160519_site_visitas.rb new file mode 100644 index 0000000..9adc908 --- /dev/null +++ b/db/migrate/20120411160519_site_visitas.rb @@ -0,0 +1,13 @@ +class SiteVisitas < ActiveRecord::Migration + def up + change_table :sites do |t| + t.column :visitas, :integer, :default => 0 + end + end + + def down + change_table :sites do |t| + t.remove :visitas + end + end +end diff --git a/db/migrate/20120417170638_create_trips.rb b/db/migrate/20120417170638_create_trips.rb new file mode 100644 index 0000000..9acf33c --- /dev/null +++ b/db/migrate/20120417170638_create_trips.rb @@ -0,0 +1,12 @@ +class CreateTrips < ActiveRecord::Migration + def change + create_table :trips do |t| + t.string :name + t.text :description + t.date :date + t.integer :user_id + + t.timestamps + end + end +end diff --git a/db/migrate/20120417172936_create_visits.rb b/db/migrate/20120417172936_create_visits.rb new file mode 100644 index 0000000..248b6be --- /dev/null +++ b/db/migrate/20120417172936_create_visits.rb @@ -0,0 +1,11 @@ +class CreateVisits < ActiveRecord::Migration + def change + create_table :visits do |t| + t.integer :trip_id + t.integer :site_id + t.integer :hour + + t.timestamps + end + end +end diff --git a/db/migrate/20120417205239_coords.rb b/db/migrate/20120417205239_coords.rb new file mode 100644 index 0000000..d126511 --- /dev/null +++ b/db/migrate/20120417205239_coords.rb @@ -0,0 +1,18 @@ +class Coords < ActiveRecord::Migration + def up + change_table :sites do |t| + t.column :longitud,:float + t.column :latitud, :float + t.column :zoom, :integer + end + end + + def down + change_table :sites do |t| + t.remove :longitud + t.remove :latitud + t.remove :zoom + end + + end +end diff --git a/db/migrate/20120417205239_coords.rb~ b/db/migrate/20120417205239_coords.rb~ new file mode 100644 index 0000000..9d96f17 --- /dev/null +++ b/db/migrate/20120417205239_coords.rb~ @@ -0,0 +1,7 @@ +class Coords < ActiveRecord::Migration + def up + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index de057ba..67fd723 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,13 +11,39 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120320100145) do +ActiveRecord::Schema.define(:version => 20120417205239) do + + create_table "comments", :force => true do |t| + t.string "comment" + t.integer "user_id" + t.integer "site_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end create_table "sites", :force => true do |t| t.string "name" t.text "description" t.integer "type_id" t.string "image_url" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "user_id" + t.string "image_file_name" + t.string "image_content_type" + t.string "image_file_size" + t.datetime "image_updated_at" + t.integer "visitas", :default => 0 + t.float "longitud" + t.float "latitud" + t.integer "zoom" + end + + create_table "trips", :force => true do |t| + t.string "name" + t.text "description" + t.date "date" + t.integer "user_id" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end @@ -29,4 +55,31 @@ t.datetime "updated_at", :null => false end + create_table "users", :force => true do |t| + t.string "email", :default => "", :null => false + t.string "encrypted_password", :default => "", :null => false + t.string "reset_password_token" + t.datetime "reset_password_sent_at" + t.datetime "remember_created_at" + t.integer "sign_in_count", :default => 0 + t.datetime "current_sign_in_at" + t.datetime "last_sign_in_at" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "name" + end + + add_index "users", ["email"], :name => "index_users_on_email", :unique => true + add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true + + create_table "visits", :force => true do |t| + t.integer "trip_id" + t.integer "site_id" + t.integer "hour" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + end diff --git a/db/seeds.rb b/db/seeds.rb index 99c1f6a..7cecf8e 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,52 +1,117 @@ -# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). -# -# Examples: -# -# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) -# Mayor.create(name: 'Emanuel', city: cities.first) - -Type.create( - name: 'Monumento', - description: 'Edificio de interes turistico o artistico') - -Type.create( - name: 'Naturaleza', - description: 'Lugar al aire libre de interes natural o de recreo') - -Type.create( - name: 'Ruina', - description: 'Lugar o resto de interes arquelogico') - - -Site.create( - name: 'Pedriza', - description: 'Magnifico valle al norte de Madrid en el Macizo Central', - type_id: 2, - image_url: 'pedriza.png') - -Site.create( - name: 'Catedral de Florencia', - description: 'Catedral de la ciudad de Florencia con la que se inicia el Renacimiento', - type_id: 1, - image_url: 'florencia.png') - -Site.create( - name: 'Jardin de Lineo', - description: 'Jardin de la ciudad sueca de Uppsala donde el famoso naturalista enia su coleccion de plantas', - type_id: 2, - image_url: 'arbol1.png') - -Site.create( - name: 'Reichstag', - description: 'Parlamento aleman en la ciudad de Berlin', - type_id: 1, - image_url: 'reichstag.png') - -Site.create( - name: 'Pergamo', - description: 'Puerta del mercado de la antigua ciudad griega de Pergamo del museo arquelogico de Berlin', - type_id: 3, - image_url: 'pergamo.png') - - +# This file should contain all the record creation needed to seed the +# database with its default values. The data can then be loaded with +# the rake db:seed (or created alongside the db with db:setup). +# +# Examples: +# +# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) +# Mayor.create(name: 'Emanuel', city: cities.first) + +Type.delete_all + +type1 = Type.create!( + name: 'Monumento', + description: 'Edificio de interes turistico o artistico') + +type2 = Type.create!( + name: 'Naturaleza', + description: 'Lugar al aire libre de interes natural o de recreo') + +type3 = Type.create!( + name: 'Ruina', + description: 'Lugar o resto de interes arquelogico') + + +User.delete_all + +user1 = User.create!( + name: 'Jose Perez', + email: 'jose.perez@gmail.com', + password: 'perez22', + password_confirmation: 'perez22') + +user2 = User.create!( + name: 'Javier Sedano', + email: 'javier.sedano@me.com', + password: 'sedano22', + password_confirmation: 'sedano22') + + +Site.delete_all + +site1= Site.create!( + name: 'Pedriza', + description: 'Magnifico valle al norte de Madrid en el Macizo Central', + type_id: type2.id, + image_url: 'pedriza.png', + image: File.open(File.join(Rails.root, 'app', 'assets','images', 'pedriza.png'), "r")) +site1.user_id = user1.id ; site1.save + +site2 = Site.create!( + name: 'Catedral de Florencia', + description: 'Catedral de la ciudad de Florencia con la que se inicia el Renacimiento', + type_id: type1.id, + image_url: 'florencia.png', + image: File.open(File.join(Rails.root, 'app', 'assets','images', 'florencia.png'), "r")) +site2.user_id = user1.id ; site2.save + +site3 = Site.create!( + name: 'Jardin de Lineo', + description: 'Jardin de la ciudad sueca de Uppsala donde el famoso naturalista tenia su coleccion de plantas', + type_id: type1.id, + image_url: 'arbol1.png', + image: File.open(File.join(Rails.root, 'app', 'assets','images', 'arbol1.png'), "r")) +site3.user_id = user2.id ; site3.save + +site4 = Site.create!( + name: 'Reichstag', + description: 'Parlamento aleman en la ciudad de Berlin', + type_id: type2.id, + image_url: 'reichstag.png', + image: File.open(File.join(Rails.root, 'app', 'assets','images', 'reichstag.png'), "r")) +site4.user_id = user2.id ; site4.save + +site5 = Site.create!( + name: 'Pergamo', + description: 'Puerta del mercado de la antigua ciudad griega de Pergamo del museo arquelogico de Berlin', + type_id: type3.id, + image_url: 'pergamo.png', + image: File.open(File.join(Rails.root, 'app', 'assets','images', 'pergamo.png'), "r")) +site5.user_id = user1.id ; site5.save + + + +Trip.delete_all + +trip1 = Trip.create!( + name: 'Viaje por Europa', + description: 'Viaje por capitales europeas', + date: '2012-04-12') +trip1.user_id = user1.id ; trip1.save + +trip2 = Trip.create!( + name: 'Sierra de Madrid', + description: 'Sua al Yelmo en la Pedriza', + date: '2012-05-18') +trip2.user_id = user2.id ; trip2.save + + +Visit.delete_all + +visit1 = Visit.create!( + hour: '10') +visit1.trip_id = trip2.id +visit1.site_id = site1.id ; visit1.save + +visit2 = Visit.create!( + hour: '9') +visit2.trip_id = trip1.id +visit2.site_id = site5.id ; visit2.save + +visit3 = Visit.create!( + hour: '16') +visit3.trip_id = trip1.id +visit3.site_id = site4.id ; visit3.save + + + diff --git a/doc/README_FOR_APP b/doc/README_FOR_APP index fe41f5c..ab562a4 100644 --- a/doc/README_FOR_APP +++ b/doc/README_FOR_APP @@ -1,2 +1,2 @@ -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. +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. diff --git a/doc/app/ApplicationController.html b/doc/app/ApplicationController.html new file mode 100644 index 0000000..fd3724e --- /dev/null +++ b/doc/app/ApplicationController.html @@ -0,0 +1,163 @@ + + + + + + +class ApplicationController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class ApplicationController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/ApplicationHelper.html b/doc/app/ApplicationHelper.html new file mode 100644 index 0000000..2592c04 --- /dev/null +++ b/doc/app/ApplicationHelper.html @@ -0,0 +1,157 @@ + + + + + + +module ApplicationHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module ApplicationHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Comment.html b/doc/app/Comment.html new file mode 100644 index 0000000..ebe03b1 --- /dev/null +++ b/doc/app/Comment.html @@ -0,0 +1,170 @@ + + + + + + +class Comment - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Comment

+ +
+ +

Qué define este modelo

+ +

El modelo de comments define los comentarios que los usuarios hagan sobre +los sitios. Cada comentario pertenece a un usuario y a un sitio +determinado. Por defecto se ha establecido un máximo de 240 caracteres para +cada comentario.

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/CommentsController.html b/doc/app/CommentsController.html new file mode 100644 index 0000000..d35dc81 --- /dev/null +++ b/doc/app/CommentsController.html @@ -0,0 +1,494 @@ + + + + + + +class CommentsController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class CommentsController

+ +
+ +

Qué hace este controlador

+ +

El controlador de comments gestiona todo lo relacionado con la creación, +edición y eliminación de comentarios. Trabaja con Devise para identificar +cada comentario con el usuario que lo creó. Tiene un filtro para ejecutar +las acciones sólo si se ha iniciado sesión. Este filtro no afecta a las +acciones index y show.

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

Método que crea el nuevo comentario. Rutas:

+
  • +

    POST /comments

    +
  • +

    POST /comments.js

    +
  • +

    POST /comments.json

    +
+ + + +
+
# File app/controllers/comments_controller.rb, line 62
+def create
+  @comment = current_user.comments.build(params[:comment])
+  @site = @comment.site
+
+  respond_to do |format|
+    if @comment.save
+      format.html { redirect_to site_path(@site), notice: 'Comment was successfully created.' }
+      format.js
+      format.json { render json: @comment, status: :created, location: @comment }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @comment.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

Método que permite eliminar un comentario. Rutas:

+
  • +

    DELETE /comments/:id

    +
  • +

    DELETE /comments/:id.json

    +
+ + + +
+
# File app/controllers/comments_controller.rb, line 99
+def destroy
+  @comment = current_user.comments.find(params[:id])
+  site = @comment.site
+  @comment.destroy
+
+  respond_to do |format|
+    format.html { redirect_to site_path(site) }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

Método que permite editar el comentario seleccionado. Ruta:

+
  • +

    GET /comments/:id/edit

    +
+ + + +
+
# File app/controllers/comments_controller.rb, line 53
+def edit
+  @comment = current_user.comments.find(params[:id])
+  @site = @comment.site
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

Método que muestra los comentarios asociados al sitio seleccionado. Rutas:

+
  • +

    GET /sites/:site_id/comments

    +
  • +

    GET /sites/:site_id/comments.json

    +
+ + + +
+
# File app/controllers/comments_controller.rb, line 15
+def index
+  @site = Site.find(params[:site_id])
+  @comments = @site.comments
+  @comment = current_user.comments.build if current_user
+
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @comments }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

Método que permite modificar un nuevo comentario asociado a un sitio. +Rutas:

+
  • +

    GET /sites/:site_id/comments/new

    +
  • +

    GET /sites/:site_id/comments/new.json

    +
+ + + +
+
# File app/controllers/comments_controller.rb, line 41
+def new
+  @comment = current_user.comments.build
+  @site = Site.find(params[:site_id])
+
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @comment }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

Método que muestra el comentario seleccionado. Rutas:

+
  • +

    GET /comments/:comment_id

    +
  • +

    GET /comments/:comment_id.json

    +
+ + + +
+
# File app/controllers/comments_controller.rb, line 29
+def show
+  @comment = Comment.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @comment }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

Método que actualiza el comentario editado. Rutas:

+
  • +

    PUT /comments/:id

    +
  • +

    PUT /comments/:id.json

    +
+ + + +
+
# File app/controllers/comments_controller.rb, line 81
+def update
+  @comment = current_user.comments.find(params[:id])
+  @site = @comment.site
+
+  respond_to do |format|
+    if @comment.update_attributes(params[:comment])
+      format.html { redirect_to site_path(@site), notice: 'Comment was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @comment.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/CommentsHelper.html b/doc/app/CommentsHelper.html new file mode 100644 index 0000000..bfebd8f --- /dev/null +++ b/doc/app/CommentsHelper.html @@ -0,0 +1,157 @@ + + + + + + +module CommentsHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module CommentsHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/PlanetController.html b/doc/app/PlanetController.html new file mode 100644 index 0000000..c3d8e96 --- /dev/null +++ b/doc/app/PlanetController.html @@ -0,0 +1,399 @@ + + + + + + +class PlanetController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class PlanetController

+ +
+ +

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 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

    +
    • +

      permite generar letra de teletipo, igual que con +HTML

      +
    +
+ +

Qué hace este controlador

+ +

El controlador de planet es en gran parte un controlador de prueba con +acciones vacías. Sólo hay un método con una acción completa, search. Esta +acción busca los sitios o viajes que tengan en su nombre o en su +descripción la cadena de texto introducida.

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ author() + click to toggle source +
+ + +
+ +

Método que define una acción vacía del controlador. Ruta:

+
  • +

    GET /planet/author

    +
+ + + +
+
# File app/controllers/planet_controller.rb, line 44
+def author
+end
+
+ +
+ + + + +
+ + +
+ +
+ contact() + click to toggle source +
+ + +
+ +

Método que define una acción vacía del controlador. Ruta:

+
  • +

    GET /planet/contact

    +
+ + + +
+
# File app/controllers/planet_controller.rb, line 34
+def contact
+end
+
+ +
+ + + + +
+ + +
+ +
+ ejemplo() + click to toggle source +
+ + +
+ +

Método que define una acción vacía del controlador. Ruta:

+
  • +

    GET /planet/ejemplo

    +
+ + + +
+
# File app/controllers/planet_controller.rb, line 39
+def ejemplo
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

Método que define una acción vacía del controlador. Ruta:

+
  • +

    GET /planet/index

    +
+ + + +
+
# File app/controllers/planet_controller.rb, line 29
+def index
+end
+
+ +
+ + + + +
+ + + + + +
+ +
+ +
+ + + + diff --git a/doc/app/PlanetHelper.html b/doc/app/PlanetHelper.html new file mode 100644 index 0000000..4f02ec7 --- /dev/null +++ b/doc/app/PlanetHelper.html @@ -0,0 +1,157 @@ + + + + + + +module PlanetHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module PlanetHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Site.html b/doc/app/Site.html new file mode 100644 index 0000000..b55d708 --- /dev/null +++ b/doc/app/Site.html @@ -0,0 +1,173 @@ + + + + + + +class Site - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Site

+ +
+ +

Qué define este modelo

+ +

El modelo de site define un sitio, un emplazamiento en alguna parte del +mundo que se añade por su interés turístico, especificando su tipo. Un +sitio pertenece al usuario que lo ha creado y al tipo en el que se enmarca. +Sólo el usuario que lo ha creado podrá editarlo o borrarlo. Un sitio puede +ser parte de muchos viajes definido como una visita. Además puede tener +comentarios que añadan los usuarios y una imagen que lo identifique. +Obligatoriamente un sitio tiene que tener un nombre y un tipo.

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/SitesController.html b/doc/app/SitesController.html new file mode 100644 index 0000000..b17f3a8 --- /dev/null +++ b/doc/app/SitesController.html @@ -0,0 +1,494 @@ + + + + + + +class SitesController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class SitesController

+ +
+ +

Qué hace este controlador

+ +

El controlador de sites gestiona todo lo relacionado con la creación, +edición y eliminación de sitios. Trabaja con Devise para identificar cada +sitio con el usuario que lo creó. Tiene dos filtros:

+
  • +

    Uno para ejecutar las acciones sólo si antes se ha iniciado sesión. Este +filtro no afecta a las acciones index y show.

    +
  • +

    Otro para ejecutar el método que define la acción count_visita después de +la carga de la página.

    +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

Método que crea el nuevo sitio. Rutas:

+
  • +

    POST /sites

    +
  • +

    POST /sites.json

    +
+ + + +
+
# File app/controllers/sites_controller.rb, line 63
+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
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

Método que permite eliminar un sitio. Rutas:

+
  • +

    DELETE /sites/:id

    +
  • +

    DELETE /sites/:id.json

    +
+ + + +
+
# File app/controllers/sites_controller.rb, line 97
+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
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

Método que permite editar el sitio seleccionado. Ruta:

+
  • +

    GET /sites/:id/edit

    +
+ + + +
+
# File app/controllers/sites_controller.rb, line 56
+def edit
+  @site = current_user.sites.find(params[:id])  # busca solo en sitios asociados a current_user
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

Este método muestra todos los sitios si no se ha especificado un tipo o los +sitios de un tipo determinado. Rutas:

+
  • +

    GET /sites

    +
  • +

    GET /sites.json

    +
+ + + +
+
# File app/controllers/sites_controller.rb, line 16
+def index
+  if params[:type_id].nil? or params[:type_id].empty?
+    @sites = Site.all            # path: /sites
+  else
+    @sites = Type.find(params[:type_id]).sites  # path: /types/:type_id/sites
+  end
+  
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @sites }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

Método que permite modificar un nuevo sitio. Rutas:

+
  • +

    GET /sites/new

    +
  • +

    GET /sites/new.json

    +
+ + + +
+
# File app/controllers/sites_controller.rb, line 45
+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
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

Método que muestra el sitio seleccionado. Rutas:

+
  • +

    GET /sites/:id

    +
  • +

    GET /sites/:id.json

    +
+ + + +
+
# File app/controllers/sites_controller.rb, line 32
+def show
+  @site = Site.find(params[:id])
+  @comment = current_user.comments.build if current_user
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @site }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

Método que actualiza el sitio editado. Rutas:

+
  • +

    PUT /sites/:id

    +
  • +

    PUT /sites/:id.json

    +
+ + + +
+
# File app/controllers/sites_controller.rb, line 80
+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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/SitesHelper.html b/doc/app/SitesHelper.html new file mode 100644 index 0000000..4e08fe9 --- /dev/null +++ b/doc/app/SitesHelper.html @@ -0,0 +1,157 @@ + + + + + + +module SitesHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module SitesHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Trip.html b/doc/app/Trip.html new file mode 100644 index 0000000..f73b43d --- /dev/null +++ b/doc/app/Trip.html @@ -0,0 +1,169 @@ + + + + + + +class Trip - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Trip

+ +
+ +

Qué define este modelo

+ +

El modelo de trips define los viajes que se pueden hacer. Cada viaje +pertenece a un usuario determinado e incluye una serie de visitas (una +serie de sitios a los que se pretende ir a una hora determinada).

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/TripsController.html b/doc/app/TripsController.html new file mode 100644 index 0000000..07a83a7 --- /dev/null +++ b/doc/app/TripsController.html @@ -0,0 +1,484 @@ + + + + + + +class TripsController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class TripsController

+ +
+ +

Qué hace este controlador

+ +

El controlador de trips gestiona todo lo relacionado con la creación, +edición y eliminación de viajes. Trabaja con Devise para identificar cada +viaje con el usuario que lo creó y con visits, que componen un viaje. Tiene +un filtro para ejecutar las acciones sólo si antes se ha iniciado sesión. +Este filtro no afecta a las acciones index y show.

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

Método que crea el nuevo viaje. Rutas:

+
  • +

    POST /trips

    +
  • +

    POST /trips.json

    +
+ + + +
+
# File app/controllers/trips_controller.rb, line 57
+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
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

Método que permite eliminar un viaje. Rutas:

+
  • +

    DELETE /trips/:id

    +
  • +

    DELETE /trips/:id.json

    +
+ + + +
+
# File app/controllers/trips_controller.rb, line 91
+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
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

Método que permite editar el viaje seleccionado. Ruta:

+
  • +

    GET /trips/:id/edit

    +
+ + + +
+
# File app/controllers/trips_controller.rb, line 50
+def edit
+  @trip = current_user.trips.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

Método que muestra todos los viajes. Rutas:

+
  • +

    GET /trips

    +
  • +

    GET /trips.json

    +
+ + + +
+
# File app/controllers/trips_controller.rb, line 14
+def index
+  @trips = Trip.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @trips }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

Método que permite modificar un nuevo viaje. Rutas:

+
  • +

    GET /trips/new

    +
  • +

    GET /trips/new.json

    +
+ + + +
+
# File app/controllers/trips_controller.rb, line 39
+def new
+  @trip = current_user.trips.build
+
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @trip }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

Método que muestra el viaje seleccionado. Rutas:

+
  • +

    GET /trips/:id

    +
  • +

    GET /trips/:id.json

    +
+ + + +
+
# File app/controllers/trips_controller.rb, line 26
+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
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

Método que actualiza el viaje editado. Rutas:

+
  • +

    PUT /trips/:id

    +
  • +

    PUT /trips/:id.json

    +
+ + + +
+
# File app/controllers/trips_controller.rb, line 74
+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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/TripsHelper.html b/doc/app/TripsHelper.html new file mode 100644 index 0000000..12597fd --- /dev/null +++ b/doc/app/TripsHelper.html @@ -0,0 +1,157 @@ + + + + + + +module TripsHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module TripsHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Type.html b/doc/app/Type.html new file mode 100644 index 0000000..cefcd8c --- /dev/null +++ b/doc/app/Type.html @@ -0,0 +1,172 @@ + + + + + + +class Type - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Type

+ +
+ +

Qué define este modelo

+ +

El modelo de types define los tipos o categorías en los que se puede +clasificar cada sitio. Un tipo agrupa a varios sitios que comparten unas +caracterícas determinadas (como por ejemplo estar en medio de la naturaleza +o ser un edificio histórico). Un tipo tiene que tener obligatoriamente un +nombre y una descripción, pero no pueden existir dos sitios con el mismo +nombre.

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/TypesController.html b/doc/app/TypesController.html new file mode 100644 index 0000000..70b9971 --- /dev/null +++ b/doc/app/TypesController.html @@ -0,0 +1,524 @@ + + + + + + +class TypesController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class TypesController

+ +
+ +

Qué hace este controlador

+ +

El controlador de tipos gestiona todo lo relacionado con la creación, +edición y eliminación de tipos. Cualquier usuario puede realizar acciones +sobre los tipos.

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

Método que crea el nuevo tipo. Rutas:

+
  • +

    POST /types

    +
  • +

    POST /types.json

    +
+ + + +
+
# File app/controllers/types_controller.rb, line 63
+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
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

Método que permite eliminar un tipo. Rutas:

+
  • +

    DELETE /types/:id

    +
  • +

    DELETE /types/:id.json

    +
+ + + +
+
# File app/controllers/types_controller.rb, line 97
+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
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

Método que permite editar el tipo seleccionado. Ruta:

+
  • +

    GET /types/:id/edit

    +
+ + + +
+
# File app/controllers/types_controller.rb, line 56
+def edit
+  @type = Type.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

Método que muestra todos los tipos. Rutas:

+
  • +

    GET /types

    +
  • +

    GET /types.json

    +
+ + + +
+
# File app/controllers/types_controller.rb, line 9
+def index
+  @types = Type.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @types }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

Método que permite modificar un nuevo tipo. Rutas:

+
  • +

    GET /types/new

    +
  • +

    GET /types/new.json

    +
+ + + +
+
# File app/controllers/types_controller.rb, line 45
+def new
+  @type = Type.new
+
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @type }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ ordered_index() + click to toggle source +
+ + +
+ +

Este método define una acción que muestra todos los tipos por orden +alfabético. Rutas:

+
  • +

    GET /types/ordered_index

    +
  • +

    GET /types/ordered_index.json

    +
+ + + +
+
# File app/controllers/types_controller.rb, line 33
+def ordered_index
+  @types = Type.find(:all, :order => :name) 
+
+  respond_to do |format|
+    format.html # ordered_index.html.erb
+    format.json { render json: @types }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

Método que muestra el tipo seleccionado. Rutas:

+
  • +

    GET /types/:id

    +
  • +

    GET /types/:id.json

    +
+ + + +
+
# File app/controllers/types_controller.rb, line 21
+def show
+  @type = Type.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @type }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

Método que actualiza el tipo editado. Rutas:

+
  • +

    PUT /types/:id

    +
  • +

    PUT /types/:id.json

    +
+ + + +
+
# File app/controllers/types_controller.rb, line 80
+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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/TypesHelper.html b/doc/app/TypesHelper.html new file mode 100644 index 0000000..3ea694b --- /dev/null +++ b/doc/app/TypesHelper.html @@ -0,0 +1,157 @@ + + + + + + +module TypesHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module TypesHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/User.html b/doc/app/User.html new file mode 100644 index 0000000..5ed07e6 --- /dev/null +++ b/doc/app/User.html @@ -0,0 +1,172 @@ + + + + + + +class User - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class User

+ +
+ +

Qué define este modelo

+ +

El modelo de users define los usuarios de esta página web. Cada persona +debe crearse un usario que le identifique dentro de la página web, +especificando un nombre, una contraseña para evitar accesos indeseados y la +suplantación de su identidad y un correo para recibir avisos y recuperar la +contraseña. Un usuario es dueño de todos los sitios, comentarios y viajes +que haya creado, y como tal sólo él podrá editarlos o borrarlos.

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Visit.html b/doc/app/Visit.html new file mode 100644 index 0000000..faac23b --- /dev/null +++ b/doc/app/Visit.html @@ -0,0 +1,168 @@ + + + + + + +class Visit - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Visit

+ +
+ +

Qué define este modelo

+ +

El modelo de visits define las visitas que componen cada viaje, es decir, +los sitios que se desean visitar en dicho viaje.

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/VisitsController.html b/doc/app/VisitsController.html new file mode 100644 index 0000000..978bd52 --- /dev/null +++ b/doc/app/VisitsController.html @@ -0,0 +1,484 @@ + + + + + + +class VisitsController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class VisitsController

+ +
+ +

Qué hace este controlador

+ +

El controlador de tipos gestiona todo lo relacionado con la creación, +edición y eliminación de tipos. Como las visitas se renderizan con los +viajes, se controla indirectamente qué usuario realiza estas acciones.

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

Método que crea la nueva visita. Rutas:

+
  • +

    POST /visits

    +
  • +

    POST /visits.js

    +
  • +

    POST /visits.json

    +
+ + + +
+
# File app/controllers/visits_controller.rb, line 52
+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
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

Método que permite eliminar una visita. Rutas:

+
  • +

    DELETE /visits/1

    +
  • +

    DELETE /visits/1.json

    +
+ + + +
+
# File app/controllers/visits_controller.rb, line 87
+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
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

Método que permite editar la visita seleccionada. Ruta:

+
  • +

    GET /visits/1/edit

    +
+ + + +
+
# File app/controllers/visits_controller.rb, line 44
+def edit
+  @visit = Visit.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

Método que muestra todos las visitas. Rutas:

+
  • +

    GET /visits

    +
  • +

    GET /visits.json

    +
+ + + +
+
# File app/controllers/visits_controller.rb, line 9
+def index
+  @visits = Visit.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @visits }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

Método que permite modificar una nueva visita. Rutas:

+
  • +

    GET /visits/new

    +
  • +

    GET /visits/new.json

    +
+ + + +
+
# File app/controllers/visits_controller.rb, line 33
+def new
+  @visit = Visit.new
+
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @visit }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

Método que muestra la visita seleccionada. Rutas:

+
  • +

    GET /visits/1

    +
  • +

    GET /visits/1.json

    +
+ + + +
+
# File app/controllers/visits_controller.rb, line 21
+def show
+  @visit = Visit.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @visit }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

Método que actualiza la visita editada. Rutas:

+
  • +

    PUT /visits/1

    +
  • +

    PUT /visits/1.json

    +
+ + + +
+
# File app/controllers/visits_controller.rb, line 70
+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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/VisitsHelper.html b/doc/app/VisitsHelper.html new file mode 100644 index 0000000..83b4cf3 --- /dev/null +++ b/doc/app/VisitsHelper.html @@ -0,0 +1,157 @@ + + + + + + +module VisitsHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module VisitsHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/created.rid b/doc/app/created.rid new file mode 100644 index 0000000..399944d --- /dev/null +++ b/doc/app/created.rid @@ -0,0 +1,22 @@ +Wed, 25 Apr 2012 15:19:33 +0200 +doc/README_FOR_APP Sat, 31 Mar 2012 14:34:22 +0200 +app/controllers/application_controller.rb Sat, 31 Mar 2012 14:34:22 +0200 +app/controllers/comments_controller.rb Wed, 25 Apr 2012 13:03:23 +0200 +app/controllers/planet_controller.rb Tue, 24 Apr 2012 18:27:26 +0200 +app/controllers/sites_controller.rb Tue, 24 Apr 2012 18:29:50 +0200 +app/controllers/trips_controller.rb Wed, 25 Apr 2012 13:49:49 +0200 +app/controllers/types_controller.rb Tue, 24 Apr 2012 18:32:24 +0200 +app/controllers/visits_controller.rb Tue, 24 Apr 2012 18:34:10 +0200 +app/helpers/application_helper.rb Sat, 31 Mar 2012 14:34:22 +0200 +app/helpers/comments_helper.rb Tue, 10 Apr 2012 19:11:02 +0200 +app/helpers/planet_helper.rb Sat, 31 Mar 2012 14:34:22 +0200 +app/helpers/sites_helper.rb Sat, 31 Mar 2012 14:34:22 +0200 +app/helpers/trips_helper.rb Tue, 17 Apr 2012 19:06:38 +0200 +app/helpers/types_helper.rb Sat, 31 Mar 2012 14:34:22 +0200 +app/helpers/visits_helper.rb Tue, 17 Apr 2012 19:29:36 +0200 +app/models/comment.rb Tue, 24 Apr 2012 18:14:16 +0200 +app/models/site.rb Wed, 25 Apr 2012 14:31:32 +0200 +app/models/trip.rb Sat, 21 Apr 2012 14:53:58 +0200 +app/models/type.rb Sat, 21 Apr 2012 14:56:32 +0200 +app/models/user.rb Sat, 21 Apr 2012 14:59:36 +0200 +app/models/visit.rb Sat, 21 Apr 2012 15:01:30 +0200 diff --git a/doc/app/doc/README_FOR_APP.html b/doc/app/doc/README_FOR_APP.html new file mode 100644 index 0000000..a6bb752 --- /dev/null +++ b/doc/app/doc/README_FOR_APP.html @@ -0,0 +1,123 @@ + + + + + + +README_FOR_APP - Rails Application Documentation + + + + + + + + + + + + + + + + +
+ +

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.

+ +
+ + + + + diff --git a/doc/app/images/add.png b/doc/app/images/add.png new file mode 100644 index 0000000..6332fef Binary files /dev/null and b/doc/app/images/add.png differ diff --git a/doc/app/images/brick.png b/doc/app/images/brick.png new file mode 100644 index 0000000..7851cf3 Binary files /dev/null and b/doc/app/images/brick.png differ diff --git a/doc/app/images/brick_link.png b/doc/app/images/brick_link.png new file mode 100644 index 0000000..9ebf013 Binary files /dev/null and b/doc/app/images/brick_link.png differ diff --git a/doc/app/images/bug.png b/doc/app/images/bug.png new file mode 100644 index 0000000..2d5fb90 Binary files /dev/null and b/doc/app/images/bug.png differ diff --git a/doc/app/images/bullet_black.png b/doc/app/images/bullet_black.png new file mode 100644 index 0000000..5761970 Binary files /dev/null and b/doc/app/images/bullet_black.png differ diff --git a/doc/app/images/bullet_toggle_minus.png b/doc/app/images/bullet_toggle_minus.png new file mode 100644 index 0000000..b47ce55 Binary files /dev/null and b/doc/app/images/bullet_toggle_minus.png differ diff --git a/doc/app/images/bullet_toggle_plus.png b/doc/app/images/bullet_toggle_plus.png new file mode 100644 index 0000000..9ab4a89 Binary files /dev/null and b/doc/app/images/bullet_toggle_plus.png differ diff --git a/doc/app/images/date.png b/doc/app/images/date.png new file mode 100644 index 0000000..783c833 Binary files /dev/null and b/doc/app/images/date.png differ diff --git a/doc/app/images/delete.png b/doc/app/images/delete.png new file mode 100644 index 0000000..08f2493 Binary files /dev/null and b/doc/app/images/delete.png differ diff --git a/doc/app/images/find.png b/doc/app/images/find.png new file mode 100644 index 0000000..1547479 Binary files /dev/null and b/doc/app/images/find.png differ diff --git a/doc/app/images/loadingAnimation.gif b/doc/app/images/loadingAnimation.gif new file mode 100644 index 0000000..82290f4 Binary files /dev/null and b/doc/app/images/loadingAnimation.gif differ diff --git a/doc/app/images/macFFBgHack.png b/doc/app/images/macFFBgHack.png new file mode 100644 index 0000000..c6473b3 Binary files /dev/null and b/doc/app/images/macFFBgHack.png differ diff --git a/doc/app/images/package.png b/doc/app/images/package.png new file mode 100644 index 0000000..da3c2a2 Binary files /dev/null and b/doc/app/images/package.png differ diff --git a/doc/app/images/page_green.png b/doc/app/images/page_green.png new file mode 100644 index 0000000..de8e003 Binary files /dev/null and b/doc/app/images/page_green.png differ diff --git a/doc/app/images/page_white_text.png b/doc/app/images/page_white_text.png new file mode 100644 index 0000000..813f712 Binary files /dev/null and b/doc/app/images/page_white_text.png differ diff --git a/doc/app/images/page_white_width.png b/doc/app/images/page_white_width.png new file mode 100644 index 0000000..1eb8809 Binary files /dev/null and b/doc/app/images/page_white_width.png differ diff --git a/doc/app/images/plugin.png b/doc/app/images/plugin.png new file mode 100644 index 0000000..6187b15 Binary files /dev/null and b/doc/app/images/plugin.png differ diff --git a/doc/app/images/ruby.png b/doc/app/images/ruby.png new file mode 100644 index 0000000..f763a16 Binary files /dev/null and b/doc/app/images/ruby.png differ diff --git a/doc/app/images/tag_blue.png b/doc/app/images/tag_blue.png new file mode 100644 index 0000000..3f02b5f Binary files /dev/null and b/doc/app/images/tag_blue.png differ diff --git a/doc/app/images/tag_green.png b/doc/app/images/tag_green.png new file mode 100644 index 0000000..83ec984 Binary files /dev/null and b/doc/app/images/tag_green.png differ diff --git a/doc/app/images/transparent.png b/doc/app/images/transparent.png new file mode 100644 index 0000000..d665e17 Binary files /dev/null and b/doc/app/images/transparent.png differ diff --git a/doc/app/images/wrench.png b/doc/app/images/wrench.png new file mode 100644 index 0000000..5c8213f Binary files /dev/null and b/doc/app/images/wrench.png differ diff --git a/doc/app/images/wrench_orange.png b/doc/app/images/wrench_orange.png new file mode 100644 index 0000000..565a933 Binary files /dev/null and b/doc/app/images/wrench_orange.png differ diff --git a/doc/app/images/zoom.png b/doc/app/images/zoom.png new file mode 100644 index 0000000..908612e Binary files /dev/null and b/doc/app/images/zoom.png differ diff --git a/doc/app/index.html b/doc/app/index.html new file mode 100644 index 0000000..6519925 --- /dev/null +++ b/doc/app/index.html @@ -0,0 +1,116 @@ + + + + + + +Documentacion de Planet + + + + + + + + + + + + + + + + +

Esta es la documentación generada para Planet. + + +

+ diff --git a/doc/app/index.html~ b/doc/app/index.html~ new file mode 100644 index 0000000..d1b7d1a --- /dev/null +++ b/doc/app/index.html~ @@ -0,0 +1,116 @@ + + + + + + +Documentacion de Planet + + + + + + + + + + + + + + + + +

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 + * + */ + +/* Provide console simulation for firebug-less environments */ +if (!("console" in window) || !("firebug" in console)) { + var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", + "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; + + window.console = {}; + for (var i = 0; i < names.length; ++i) + window.console[names[i]] = function() {}; +}; + + +/** + * Unwrap the first element that matches the given @expr@ from the targets and return them. + */ +$.fn.unwrap = function( expr ) { + return this.each( function() { + $(this).parents( expr ).eq( 0 ).after( this ).remove(); + }); +}; + + +function showSource( e ) { + var target = e.target; + var codeSections = $(target). + parents('.method-detail'). + find('.method-source-code'); + + $(target). + parents('.method-detail'). + find('.method-source-code'). + slideToggle(); +}; + +function hookSourceViews() { + $('.method-heading').click( showSource ); +}; + +function toggleDebuggingSection() { + $('.debugging-section').slideToggle(); +}; + +function hookDebuggingToggle() { + $('#debugging-toggle img').click( toggleDebuggingSection ); +}; + +function hookTableOfContentsToggle() { + $('.indexpage li .toc-toggle').each( function() { + $(this).click( function() { + $(this).toggleClass('open'); + }); + + var section = $(this).next(); + + $(this).click( function() { + section.slideToggle(); + }); + }); +} + +function hookSearch() { + var input = $('#search-field').eq(0); + var result = $('#search-results').eq(0); + $(result).show(); + + var search_section = $('#search-section').get(0); + $(search_section).show(); + + var search = new Search(search_data, input, result); + + search.renderItem = function(result) { + var li = document.createElement('li'); + var html = ''; + + // TODO add relative path to + + + + + + + + + + +

Table of Contents - Rails Application Documentation

+ +

Pages

+ + +

Classes/Modules

+ + +

Methods

+ + + + + diff --git a/public/404.html b/public/404.html index 9a48320..a58079f 100644 --- a/public/404.html +++ b/public/404.html @@ -1,26 +1,26 @@ - - - - The page you were looking for doesn't exist (404) - - - - - -
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

-
- - + + + + The page you were looking for doesn't exist (404) + + + + + +
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+ + diff --git a/public/422.html b/public/422.html index 83660ab..cb106c4 100644 --- a/public/422.html +++ b/public/422.html @@ -1,26 +1,26 @@ - - - - The change you wanted was rejected (422) - - - - - -
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

-
- - + + + + The change you wanted was rejected (422) + + + + + +
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+ + diff --git a/public/500.html b/public/500.html index f3648a0..7029a89 100644 --- a/public/500.html +++ b/public/500.html @@ -1,25 +1,25 @@ - - - - We're sorry, but something went wrong (500) - - - - - -
-

We're sorry, but something went wrong.

-
- - + + + + We're sorry, but something went wrong (500) + + + + + +
+

We're sorry, but something went wrong.

+
+ + diff --git a/public/doc/README_FOR_APP b/public/doc/README_FOR_APP new file mode 100644 index 0000000..ab562a4 --- /dev/null +++ b/public/doc/README_FOR_APP @@ -0,0 +1,2 @@ +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. diff --git a/public/doc/app/ApplicationController.html b/public/doc/app/ApplicationController.html new file mode 100644 index 0000000..fd3724e --- /dev/null +++ b/public/doc/app/ApplicationController.html @@ -0,0 +1,163 @@ + + + + + + +class ApplicationController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class ApplicationController

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/doc/app/ApplicationHelper.html b/public/doc/app/ApplicationHelper.html new file mode 100644 index 0000000..2592c04 --- /dev/null +++ b/public/doc/app/ApplicationHelper.html @@ -0,0 +1,157 @@ + + + + + + +module ApplicationHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module ApplicationHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/doc/app/Comment.html b/public/doc/app/Comment.html new file mode 100644 index 0000000..ebe03b1 --- /dev/null +++ b/public/doc/app/Comment.html @@ -0,0 +1,170 @@ + + + + + + +class Comment - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Comment

+ +
+ +

Qué define este modelo

+ +

El modelo de comments define los comentarios que los usuarios hagan sobre +los sitios. Cada comentario pertenece a un usuario y a un sitio +determinado. Por defecto se ha establecido un máximo de 240 caracteres para +cada comentario.

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/doc/app/CommentsController.html b/public/doc/app/CommentsController.html new file mode 100644 index 0000000..d35dc81 --- /dev/null +++ b/public/doc/app/CommentsController.html @@ -0,0 +1,494 @@ + + + + + + +class CommentsController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class CommentsController

+ +
+ +

Qué hace este controlador

+ +

El controlador de comments gestiona todo lo relacionado con la creación, +edición y eliminación de comentarios. Trabaja con Devise para identificar +cada comentario con el usuario que lo creó. Tiene un filtro para ejecutar +las acciones sólo si se ha iniciado sesión. Este filtro no afecta a las +acciones index y show.

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

Método que crea el nuevo comentario. Rutas:

+
  • +

    POST /comments

    +
  • +

    POST /comments.js

    +
  • +

    POST /comments.json

    +
+ + + +
+
# File app/controllers/comments_controller.rb, line 62
+def create
+  @comment = current_user.comments.build(params[:comment])
+  @site = @comment.site
+
+  respond_to do |format|
+    if @comment.save
+      format.html { redirect_to site_path(@site), notice: 'Comment was successfully created.' }
+      format.js
+      format.json { render json: @comment, status: :created, location: @comment }
+    else
+      format.html { render action: "new" }
+      format.json { render json: @comment.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

Método que permite eliminar un comentario. Rutas:

+
  • +

    DELETE /comments/:id

    +
  • +

    DELETE /comments/:id.json

    +
+ + + +
+
# File app/controllers/comments_controller.rb, line 99
+def destroy
+  @comment = current_user.comments.find(params[:id])
+  site = @comment.site
+  @comment.destroy
+
+  respond_to do |format|
+    format.html { redirect_to site_path(site) }
+    format.json { head :no_content }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

Método que permite editar el comentario seleccionado. Ruta:

+
  • +

    GET /comments/:id/edit

    +
+ + + +
+
# File app/controllers/comments_controller.rb, line 53
+def edit
+  @comment = current_user.comments.find(params[:id])
+  @site = @comment.site
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

Método que muestra los comentarios asociados al sitio seleccionado. Rutas:

+
  • +

    GET /sites/:site_id/comments

    +
  • +

    GET /sites/:site_id/comments.json

    +
+ + + +
+
# File app/controllers/comments_controller.rb, line 15
+def index
+  @site = Site.find(params[:site_id])
+  @comments = @site.comments
+  @comment = current_user.comments.build if current_user
+
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @comments }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

Método que permite modificar un nuevo comentario asociado a un sitio. +Rutas:

+
  • +

    GET /sites/:site_id/comments/new

    +
  • +

    GET /sites/:site_id/comments/new.json

    +
+ + + +
+
# File app/controllers/comments_controller.rb, line 41
+def new
+  @comment = current_user.comments.build
+  @site = Site.find(params[:site_id])
+
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @comment }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

Método que muestra el comentario seleccionado. Rutas:

+
  • +

    GET /comments/:comment_id

    +
  • +

    GET /comments/:comment_id.json

    +
+ + + +
+
# File app/controllers/comments_controller.rb, line 29
+def show
+  @comment = Comment.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @comment }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

Método que actualiza el comentario editado. Rutas:

+
  • +

    PUT /comments/:id

    +
  • +

    PUT /comments/:id.json

    +
+ + + +
+
# File app/controllers/comments_controller.rb, line 81
+def update
+  @comment = current_user.comments.find(params[:id])
+  @site = @comment.site
+
+  respond_to do |format|
+    if @comment.update_attributes(params[:comment])
+      format.html { redirect_to site_path(@site), notice: 'Comment was successfully updated.' }
+      format.json { head :no_content }
+    else
+      format.html { render action: "edit" }
+      format.json { render json: @comment.errors, status: :unprocessable_entity }
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/doc/app/CommentsHelper.html b/public/doc/app/CommentsHelper.html new file mode 100644 index 0000000..bfebd8f --- /dev/null +++ b/public/doc/app/CommentsHelper.html @@ -0,0 +1,157 @@ + + + + + + +module CommentsHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module CommentsHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/doc/app/PlanetController.html b/public/doc/app/PlanetController.html new file mode 100644 index 0000000..c3d8e96 --- /dev/null +++ b/public/doc/app/PlanetController.html @@ -0,0 +1,399 @@ + + + + + + +class PlanetController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class PlanetController

+ +
+ +

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 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

    +
    • +

      permite generar letra de teletipo, igual que con +HTML

      +
    +
+ +

Qué hace este controlador

+ +

El controlador de planet es en gran parte un controlador de prueba con +acciones vacías. Sólo hay un método con una acción completa, search. Esta +acción busca los sitios o viajes que tengan en su nombre o en su +descripción la cadena de texto introducida.

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ author() + click to toggle source +
+ + +
+ +

Método que define una acción vacía del controlador. Ruta:

+
  • +

    GET /planet/author

    +
+ + + +
+
# File app/controllers/planet_controller.rb, line 44
+def author
+end
+
+ +
+ + + + +
+ + +
+ +
+ contact() + click to toggle source +
+ + +
+ +

Método que define una acción vacía del controlador. Ruta:

+
  • +

    GET /planet/contact

    +
+ + + +
+
# File app/controllers/planet_controller.rb, line 34
+def contact
+end
+
+ +
+ + + + +
+ + +
+ +
+ ejemplo() + click to toggle source +
+ + +
+ +

Método que define una acción vacía del controlador. Ruta:

+
  • +

    GET /planet/ejemplo

    +
+ + + +
+
# File app/controllers/planet_controller.rb, line 39
+def ejemplo
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

Método que define una acción vacía del controlador. Ruta:

+
  • +

    GET /planet/index

    +
+ + + +
+
# File app/controllers/planet_controller.rb, line 29
+def index
+end
+
+ +
+ + + + +
+ + + + + +
+ +
+ +
+ + + + diff --git a/public/doc/app/PlanetHelper.html b/public/doc/app/PlanetHelper.html new file mode 100644 index 0000000..4f02ec7 --- /dev/null +++ b/public/doc/app/PlanetHelper.html @@ -0,0 +1,157 @@ + + + + + + +module PlanetHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module PlanetHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/doc/app/Site.html b/public/doc/app/Site.html new file mode 100644 index 0000000..b55d708 --- /dev/null +++ b/public/doc/app/Site.html @@ -0,0 +1,173 @@ + + + + + + +class Site - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Site

+ +
+ +

Qué define este modelo

+ +

El modelo de site define un sitio, un emplazamiento en alguna parte del +mundo que se añade por su interés turístico, especificando su tipo. Un +sitio pertenece al usuario que lo ha creado y al tipo en el que se enmarca. +Sólo el usuario que lo ha creado podrá editarlo o borrarlo. Un sitio puede +ser parte de muchos viajes definido como una visita. Además puede tener +comentarios que añadan los usuarios y una imagen que lo identifique. +Obligatoriamente un sitio tiene que tener un nombre y un tipo.

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/doc/app/SitesController.html b/public/doc/app/SitesController.html new file mode 100644 index 0000000..b17f3a8 --- /dev/null +++ b/public/doc/app/SitesController.html @@ -0,0 +1,494 @@ + + + + + + +class SitesController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class SitesController

+ +
+ +

Qué hace este controlador

+ +

El controlador de sites gestiona todo lo relacionado con la creación, +edición y eliminación de sitios. Trabaja con Devise para identificar cada +sitio con el usuario que lo creó. Tiene dos filtros:

+
  • +

    Uno para ejecutar las acciones sólo si antes se ha iniciado sesión. Este +filtro no afecta a las acciones index y show.

    +
  • +

    Otro para ejecutar el método que define la acción count_visita después de +la carga de la página.

    +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

Método que crea el nuevo sitio. Rutas:

+
  • +

    POST /sites

    +
  • +

    POST /sites.json

    +
+ + + +
+
# File app/controllers/sites_controller.rb, line 63
+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
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

Método que permite eliminar un sitio. Rutas:

+
  • +

    DELETE /sites/:id

    +
  • +

    DELETE /sites/:id.json

    +
+ + + +
+
# File app/controllers/sites_controller.rb, line 97
+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
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

Método que permite editar el sitio seleccionado. Ruta:

+
  • +

    GET /sites/:id/edit

    +
+ + + +
+
# File app/controllers/sites_controller.rb, line 56
+def edit
+  @site = current_user.sites.find(params[:id])  # busca solo en sitios asociados a current_user
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

Este método muestra todos los sitios si no se ha especificado un tipo o los +sitios de un tipo determinado. Rutas:

+
  • +

    GET /sites

    +
  • +

    GET /sites.json

    +
+ + + +
+
# File app/controllers/sites_controller.rb, line 16
+def index
+  if params[:type_id].nil? or params[:type_id].empty?
+    @sites = Site.all            # path: /sites
+  else
+    @sites = Type.find(params[:type_id]).sites  # path: /types/:type_id/sites
+  end
+  
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @sites }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

Método que permite modificar un nuevo sitio. Rutas:

+
  • +

    GET /sites/new

    +
  • +

    GET /sites/new.json

    +
+ + + +
+
# File app/controllers/sites_controller.rb, line 45
+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
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

Método que muestra el sitio seleccionado. Rutas:

+
  • +

    GET /sites/:id

    +
  • +

    GET /sites/:id.json

    +
+ + + +
+
# File app/controllers/sites_controller.rb, line 32
+def show
+  @site = Site.find(params[:id])
+  @comment = current_user.comments.build if current_user
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @site }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

Método que actualiza el sitio editado. Rutas:

+
  • +

    PUT /sites/:id

    +
  • +

    PUT /sites/:id.json

    +
+ + + +
+
# File app/controllers/sites_controller.rb, line 80
+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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/doc/app/SitesHelper.html b/public/doc/app/SitesHelper.html new file mode 100644 index 0000000..4e08fe9 --- /dev/null +++ b/public/doc/app/SitesHelper.html @@ -0,0 +1,157 @@ + + + + + + +module SitesHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module SitesHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/doc/app/Trip.html b/public/doc/app/Trip.html new file mode 100644 index 0000000..f73b43d --- /dev/null +++ b/public/doc/app/Trip.html @@ -0,0 +1,169 @@ + + + + + + +class Trip - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Trip

+ +
+ +

Qué define este modelo

+ +

El modelo de trips define los viajes que se pueden hacer. Cada viaje +pertenece a un usuario determinado e incluye una serie de visitas (una +serie de sitios a los que se pretende ir a una hora determinada).

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/doc/app/TripsController.html b/public/doc/app/TripsController.html new file mode 100644 index 0000000..07a83a7 --- /dev/null +++ b/public/doc/app/TripsController.html @@ -0,0 +1,484 @@ + + + + + + +class TripsController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class TripsController

+ +
+ +

Qué hace este controlador

+ +

El controlador de trips gestiona todo lo relacionado con la creación, +edición y eliminación de viajes. Trabaja con Devise para identificar cada +viaje con el usuario que lo creó y con visits, que componen un viaje. Tiene +un filtro para ejecutar las acciones sólo si antes se ha iniciado sesión. +Este filtro no afecta a las acciones index y show.

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

Método que crea el nuevo viaje. Rutas:

+
  • +

    POST /trips

    +
  • +

    POST /trips.json

    +
+ + + +
+
# File app/controllers/trips_controller.rb, line 57
+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
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

Método que permite eliminar un viaje. Rutas:

+
  • +

    DELETE /trips/:id

    +
  • +

    DELETE /trips/:id.json

    +
+ + + +
+
# File app/controllers/trips_controller.rb, line 91
+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
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

Método que permite editar el viaje seleccionado. Ruta:

+
  • +

    GET /trips/:id/edit

    +
+ + + +
+
# File app/controllers/trips_controller.rb, line 50
+def edit
+  @trip = current_user.trips.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

Método que muestra todos los viajes. Rutas:

+
  • +

    GET /trips

    +
  • +

    GET /trips.json

    +
+ + + +
+
# File app/controllers/trips_controller.rb, line 14
+def index
+  @trips = Trip.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @trips }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

Método que permite modificar un nuevo viaje. Rutas:

+
  • +

    GET /trips/new

    +
  • +

    GET /trips/new.json

    +
+ + + +
+
# File app/controllers/trips_controller.rb, line 39
+def new
+  @trip = current_user.trips.build
+
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @trip }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

Método que muestra el viaje seleccionado. Rutas:

+
  • +

    GET /trips/:id

    +
  • +

    GET /trips/:id.json

    +
+ + + +
+
# File app/controllers/trips_controller.rb, line 26
+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
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

Método que actualiza el viaje editado. Rutas:

+
  • +

    PUT /trips/:id

    +
  • +

    PUT /trips/:id.json

    +
+ + + +
+
# File app/controllers/trips_controller.rb, line 74
+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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/doc/app/TripsHelper.html b/public/doc/app/TripsHelper.html new file mode 100644 index 0000000..12597fd --- /dev/null +++ b/public/doc/app/TripsHelper.html @@ -0,0 +1,157 @@ + + + + + + +module TripsHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module TripsHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/doc/app/Type.html b/public/doc/app/Type.html new file mode 100644 index 0000000..cefcd8c --- /dev/null +++ b/public/doc/app/Type.html @@ -0,0 +1,172 @@ + + + + + + +class Type - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Type

+ +
+ +

Qué define este modelo

+ +

El modelo de types define los tipos o categorías en los que se puede +clasificar cada sitio. Un tipo agrupa a varios sitios que comparten unas +caracterícas determinadas (como por ejemplo estar en medio de la naturaleza +o ser un edificio histórico). Un tipo tiene que tener obligatoriamente un +nombre y una descripción, pero no pueden existir dos sitios con el mismo +nombre.

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/doc/app/TypesController.html b/public/doc/app/TypesController.html new file mode 100644 index 0000000..70b9971 --- /dev/null +++ b/public/doc/app/TypesController.html @@ -0,0 +1,524 @@ + + + + + + +class TypesController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class TypesController

+ +
+ +

Qué hace este controlador

+ +

El controlador de tipos gestiona todo lo relacionado con la creación, +edición y eliminación de tipos. Cualquier usuario puede realizar acciones +sobre los tipos.

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

Método que crea el nuevo tipo. Rutas:

+
  • +

    POST /types

    +
  • +

    POST /types.json

    +
+ + + +
+
# File app/controllers/types_controller.rb, line 63
+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
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

Método que permite eliminar un tipo. Rutas:

+
  • +

    DELETE /types/:id

    +
  • +

    DELETE /types/:id.json

    +
+ + + +
+
# File app/controllers/types_controller.rb, line 97
+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
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

Método que permite editar el tipo seleccionado. Ruta:

+
  • +

    GET /types/:id/edit

    +
+ + + +
+
# File app/controllers/types_controller.rb, line 56
+def edit
+  @type = Type.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

Método que muestra todos los tipos. Rutas:

+
  • +

    GET /types

    +
  • +

    GET /types.json

    +
+ + + +
+
# File app/controllers/types_controller.rb, line 9
+def index
+  @types = Type.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @types }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

Método que permite modificar un nuevo tipo. Rutas:

+
  • +

    GET /types/new

    +
  • +

    GET /types/new.json

    +
+ + + +
+
# File app/controllers/types_controller.rb, line 45
+def new
+  @type = Type.new
+
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @type }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ ordered_index() + click to toggle source +
+ + +
+ +

Este método define una acción que muestra todos los tipos por orden +alfabético. Rutas:

+
  • +

    GET /types/ordered_index

    +
  • +

    GET /types/ordered_index.json

    +
+ + + +
+
# File app/controllers/types_controller.rb, line 33
+def ordered_index
+  @types = Type.find(:all, :order => :name) 
+
+  respond_to do |format|
+    format.html # ordered_index.html.erb
+    format.json { render json: @types }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

Método que muestra el tipo seleccionado. Rutas:

+
  • +

    GET /types/:id

    +
  • +

    GET /types/:id.json

    +
+ + + +
+
# File app/controllers/types_controller.rb, line 21
+def show
+  @type = Type.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @type }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

Método que actualiza el tipo editado. Rutas:

+
  • +

    PUT /types/:id

    +
  • +

    PUT /types/:id.json

    +
+ + + +
+
# File app/controllers/types_controller.rb, line 80
+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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/doc/app/TypesHelper.html b/public/doc/app/TypesHelper.html new file mode 100644 index 0000000..3ea694b --- /dev/null +++ b/public/doc/app/TypesHelper.html @@ -0,0 +1,157 @@ + + + + + + +module TypesHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module TypesHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/doc/app/User.html b/public/doc/app/User.html new file mode 100644 index 0000000..5ed07e6 --- /dev/null +++ b/public/doc/app/User.html @@ -0,0 +1,172 @@ + + + + + + +class User - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class User

+ +
+ +

Qué define este modelo

+ +

El modelo de users define los usuarios de esta página web. Cada persona +debe crearse un usario que le identifique dentro de la página web, +especificando un nombre, una contraseña para evitar accesos indeseados y la +suplantación de su identidad y un correo para recibir avisos y recuperar la +contraseña. Un usuario es dueño de todos los sitios, comentarios y viajes +que haya creado, y como tal sólo él podrá editarlos o borrarlos.

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/doc/app/Visit.html b/public/doc/app/Visit.html new file mode 100644 index 0000000..faac23b --- /dev/null +++ b/public/doc/app/Visit.html @@ -0,0 +1,168 @@ + + + + + + +class Visit - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Visit

+ +
+ +

Qué define este modelo

+ +

El modelo de visits define las visitas que componen cada viaje, es decir, +los sitios que se desean visitar en dicho viaje.

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/doc/app/VisitsController.html b/public/doc/app/VisitsController.html new file mode 100644 index 0000000..978bd52 --- /dev/null +++ b/public/doc/app/VisitsController.html @@ -0,0 +1,484 @@ + + + + + + +class VisitsController - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class VisitsController

+ +
+ +

Qué hace este controlador

+ +

El controlador de tipos gestiona todo lo relacionado con la creación, +edición y eliminación de tipos. Como las visitas se renderizan con los +viajes, se controla indirectamente qué usuario realiza estas acciones.

+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create() + click to toggle source +
+ + +
+ +

Método que crea la nueva visita. Rutas:

+
  • +

    POST /visits

    +
  • +

    POST /visits.js

    +
  • +

    POST /visits.json

    +
+ + + +
+
# File app/controllers/visits_controller.rb, line 52
+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
+
+ +
+ + + + +
+ + +
+ +
+ destroy() + click to toggle source +
+ + +
+ +

Método que permite eliminar una visita. Rutas:

+
  • +

    DELETE /visits/1

    +
  • +

    DELETE /visits/1.json

    +
+ + + +
+
# File app/controllers/visits_controller.rb, line 87
+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
+
+ +
+ + + + +
+ + +
+ +
+ edit() + click to toggle source +
+ + +
+ +

Método que permite editar la visita seleccionada. Ruta:

+
  • +

    GET /visits/1/edit

    +
+ + + +
+
# File app/controllers/visits_controller.rb, line 44
+def edit
+  @visit = Visit.find(params[:id])
+end
+
+ +
+ + + + +
+ + +
+ +
+ index() + click to toggle source +
+ + +
+ +

Método que muestra todos las visitas. Rutas:

+
  • +

    GET /visits

    +
  • +

    GET /visits.json

    +
+ + + +
+
# File app/controllers/visits_controller.rb, line 9
+def index
+  @visits = Visit.all
+
+  respond_to do |format|
+    format.html # index.html.erb
+    format.json { render json: @visits }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new() + click to toggle source +
+ + +
+ +

Método que permite modificar una nueva visita. Rutas:

+
  • +

    GET /visits/new

    +
  • +

    GET /visits/new.json

    +
+ + + +
+
# File app/controllers/visits_controller.rb, line 33
+def new
+  @visit = Visit.new
+
+  respond_to do |format|
+    format.html # new.html.erb
+    format.json { render json: @visit }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ show() + click to toggle source +
+ + +
+ +

Método que muestra la visita seleccionada. Rutas:

+
  • +

    GET /visits/1

    +
  • +

    GET /visits/1.json

    +
+ + + +
+
# File app/controllers/visits_controller.rb, line 21
+def show
+  @visit = Visit.find(params[:id])
+
+  respond_to do |format|
+    format.html # show.html.erb
+    format.json { render json: @visit }
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update() + click to toggle source +
+ + +
+ +

Método que actualiza la visita editada. Rutas:

+
  • +

    PUT /visits/1

    +
  • +

    PUT /visits/1.json

    +
+ + + +
+
# File app/controllers/visits_controller.rb, line 70
+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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/public/doc/app/VisitsHelper.html b/public/doc/app/VisitsHelper.html new file mode 100644 index 0000000..83b4cf3 --- /dev/null +++ b/public/doc/app/VisitsHelper.html @@ -0,0 +1,157 @@ + + + + + + +module VisitsHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module VisitsHelper

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/public/doc/app/created.rid b/public/doc/app/created.rid new file mode 100644 index 0000000..399944d --- /dev/null +++ b/public/doc/app/created.rid @@ -0,0 +1,22 @@ +Wed, 25 Apr 2012 15:19:33 +0200 +doc/README_FOR_APP Sat, 31 Mar 2012 14:34:22 +0200 +app/controllers/application_controller.rb Sat, 31 Mar 2012 14:34:22 +0200 +app/controllers/comments_controller.rb Wed, 25 Apr 2012 13:03:23 +0200 +app/controllers/planet_controller.rb Tue, 24 Apr 2012 18:27:26 +0200 +app/controllers/sites_controller.rb Tue, 24 Apr 2012 18:29:50 +0200 +app/controllers/trips_controller.rb Wed, 25 Apr 2012 13:49:49 +0200 +app/controllers/types_controller.rb Tue, 24 Apr 2012 18:32:24 +0200 +app/controllers/visits_controller.rb Tue, 24 Apr 2012 18:34:10 +0200 +app/helpers/application_helper.rb Sat, 31 Mar 2012 14:34:22 +0200 +app/helpers/comments_helper.rb Tue, 10 Apr 2012 19:11:02 +0200 +app/helpers/planet_helper.rb Sat, 31 Mar 2012 14:34:22 +0200 +app/helpers/sites_helper.rb Sat, 31 Mar 2012 14:34:22 +0200 +app/helpers/trips_helper.rb Tue, 17 Apr 2012 19:06:38 +0200 +app/helpers/types_helper.rb Sat, 31 Mar 2012 14:34:22 +0200 +app/helpers/visits_helper.rb Tue, 17 Apr 2012 19:29:36 +0200 +app/models/comment.rb Tue, 24 Apr 2012 18:14:16 +0200 +app/models/site.rb Wed, 25 Apr 2012 14:31:32 +0200 +app/models/trip.rb Sat, 21 Apr 2012 14:53:58 +0200 +app/models/type.rb Sat, 21 Apr 2012 14:56:32 +0200 +app/models/user.rb Sat, 21 Apr 2012 14:59:36 +0200 +app/models/visit.rb Sat, 21 Apr 2012 15:01:30 +0200 diff --git a/public/doc/app/doc/README_FOR_APP.html b/public/doc/app/doc/README_FOR_APP.html new file mode 100644 index 0000000..a6bb752 --- /dev/null +++ b/public/doc/app/doc/README_FOR_APP.html @@ -0,0 +1,123 @@ + + + + + + +README_FOR_APP - Rails Application Documentation + + + + + + + + + + + + + + + + +
+ +

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.

+ +
+ + + + + diff --git a/public/doc/app/images/add.png b/public/doc/app/images/add.png new file mode 100644 index 0000000..6332fef Binary files /dev/null and b/public/doc/app/images/add.png differ diff --git a/public/doc/app/images/brick.png b/public/doc/app/images/brick.png new file mode 100644 index 0000000..7851cf3 Binary files /dev/null and b/public/doc/app/images/brick.png differ diff --git a/public/doc/app/images/brick_link.png b/public/doc/app/images/brick_link.png new file mode 100644 index 0000000..9ebf013 Binary files /dev/null and b/public/doc/app/images/brick_link.png differ diff --git a/public/doc/app/images/bug.png b/public/doc/app/images/bug.png new file mode 100644 index 0000000..2d5fb90 Binary files /dev/null and b/public/doc/app/images/bug.png differ diff --git a/public/doc/app/images/bullet_black.png b/public/doc/app/images/bullet_black.png new file mode 100644 index 0000000..5761970 Binary files /dev/null and b/public/doc/app/images/bullet_black.png differ diff --git a/public/doc/app/images/bullet_toggle_minus.png b/public/doc/app/images/bullet_toggle_minus.png new file mode 100644 index 0000000..b47ce55 Binary files /dev/null and b/public/doc/app/images/bullet_toggle_minus.png differ diff --git a/public/doc/app/images/bullet_toggle_plus.png b/public/doc/app/images/bullet_toggle_plus.png new file mode 100644 index 0000000..9ab4a89 Binary files /dev/null and b/public/doc/app/images/bullet_toggle_plus.png differ diff --git a/public/doc/app/images/date.png b/public/doc/app/images/date.png new file mode 100644 index 0000000..783c833 Binary files /dev/null and b/public/doc/app/images/date.png differ diff --git a/public/doc/app/images/delete.png b/public/doc/app/images/delete.png new file mode 100644 index 0000000..08f2493 Binary files /dev/null and b/public/doc/app/images/delete.png differ diff --git a/public/doc/app/images/find.png b/public/doc/app/images/find.png new file mode 100644 index 0000000..1547479 Binary files /dev/null and b/public/doc/app/images/find.png differ diff --git a/public/doc/app/images/loadingAnimation.gif b/public/doc/app/images/loadingAnimation.gif new file mode 100644 index 0000000..82290f4 Binary files /dev/null and b/public/doc/app/images/loadingAnimation.gif differ diff --git a/public/doc/app/images/macFFBgHack.png b/public/doc/app/images/macFFBgHack.png new file mode 100644 index 0000000..c6473b3 Binary files /dev/null and b/public/doc/app/images/macFFBgHack.png differ diff --git a/public/doc/app/images/package.png b/public/doc/app/images/package.png new file mode 100644 index 0000000..da3c2a2 Binary files /dev/null and b/public/doc/app/images/package.png differ diff --git a/public/doc/app/images/page_green.png b/public/doc/app/images/page_green.png new file mode 100644 index 0000000..de8e003 Binary files /dev/null and b/public/doc/app/images/page_green.png differ diff --git a/public/doc/app/images/page_white_text.png b/public/doc/app/images/page_white_text.png new file mode 100644 index 0000000..813f712 Binary files /dev/null and b/public/doc/app/images/page_white_text.png differ diff --git a/public/doc/app/images/page_white_width.png b/public/doc/app/images/page_white_width.png new file mode 100644 index 0000000..1eb8809 Binary files /dev/null and b/public/doc/app/images/page_white_width.png differ diff --git a/public/doc/app/images/plugin.png b/public/doc/app/images/plugin.png new file mode 100644 index 0000000..6187b15 Binary files /dev/null and b/public/doc/app/images/plugin.png differ diff --git a/public/doc/app/images/ruby.png b/public/doc/app/images/ruby.png new file mode 100644 index 0000000..f763a16 Binary files /dev/null and b/public/doc/app/images/ruby.png differ diff --git a/public/doc/app/images/tag_blue.png b/public/doc/app/images/tag_blue.png new file mode 100644 index 0000000..3f02b5f Binary files /dev/null and b/public/doc/app/images/tag_blue.png differ diff --git a/public/doc/app/images/tag_green.png b/public/doc/app/images/tag_green.png new file mode 100644 index 0000000..83ec984 Binary files /dev/null and b/public/doc/app/images/tag_green.png differ diff --git a/public/doc/app/images/transparent.png b/public/doc/app/images/transparent.png new file mode 100644 index 0000000..d665e17 Binary files /dev/null and b/public/doc/app/images/transparent.png differ diff --git a/public/doc/app/images/wrench.png b/public/doc/app/images/wrench.png new file mode 100644 index 0000000..5c8213f Binary files /dev/null and b/public/doc/app/images/wrench.png differ diff --git a/public/doc/app/images/wrench_orange.png b/public/doc/app/images/wrench_orange.png new file mode 100644 index 0000000..565a933 Binary files /dev/null and b/public/doc/app/images/wrench_orange.png differ diff --git a/public/doc/app/images/zoom.png b/public/doc/app/images/zoom.png new file mode 100644 index 0000000..908612e Binary files /dev/null and b/public/doc/app/images/zoom.png differ diff --git a/public/doc/app/index.html b/public/doc/app/index.html new file mode 100644 index 0000000..1bed78a --- /dev/null +++ b/public/doc/app/index.html @@ -0,0 +1,116 @@ + + + + + + +Rails Application Documentation + + + + + + + + + + + + + + + + +

This is the API documentation for Rails Application Documentation. + + +

+ diff --git a/public/doc/app/js/darkfish.js b/public/doc/app/js/darkfish.js new file mode 100644 index 0000000..4be722f --- /dev/null +++ b/public/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 + * + */ + +/* Provide console simulation for firebug-less environments */ +if (!("console" in window) || !("firebug" in console)) { + var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", + "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; + + window.console = {}; + for (var i = 0; i < names.length; ++i) + window.console[names[i]] = function() {}; +}; + + +/** + * Unwrap the first element that matches the given @expr@ from the targets and return them. + */ +$.fn.unwrap = function( expr ) { + return this.each( function() { + $(this).parents( expr ).eq( 0 ).after( this ).remove(); + }); +}; + + +function showSource( e ) { + var target = e.target; + var codeSections = $(target). + parents('.method-detail'). + find('.method-source-code'); + + $(target). + parents('.method-detail'). + find('.method-source-code'). + slideToggle(); +}; + +function hookSourceViews() { + $('.method-heading').click( showSource ); +}; + +function toggleDebuggingSection() { + $('.debugging-section').slideToggle(); +}; + +function hookDebuggingToggle() { + $('#debugging-toggle img').click( toggleDebuggingSection ); +}; + +function hookTableOfContentsToggle() { + $('.indexpage li .toc-toggle').each( function() { + $(this).click( function() { + $(this).toggleClass('open'); + }); + + var section = $(this).next(); + + $(this).click( function() { + section.slideToggle(); + }); + }); +} + +function hookSearch() { + var input = $('#search-field').eq(0); + var result = $('#search-results').eq(0); + $(result).show(); + + var search_section = $('#search-section').get(0); + $(search_section).show(); + + var search = new Search(search_data, input, result); + + search.renderItem = function(result) { + var li = document.createElement('li'); + var html = ''; + + // TODO add relative path to + + + + + + + + + + +

Table of Contents - Rails Application Documentation

+ +

Pages

+ + +

Classes/Modules

+ + +

Methods

+ + + + + diff --git a/public/robots.txt b/public/robots.txt index 085187f..caedd8e 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,5 +1,5 @@ -# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file -# -# To ban all spiders from the entire site uncomment the next two lines: -# User-Agent: * -# Disallow: / +# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file +# +# To ban all spiders from the entire site uncomment the next two lines: +# User-Agent: * +# Disallow: / diff --git a/script/rails b/script/rails old mode 100755 new mode 100644 index f8da2cf..4276b36 --- a/script/rails +++ b/script/rails @@ -1,6 +1,6 @@ -#!/usr/bin/env ruby -# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. - -APP_PATH = File.expand_path('../../config/application', __FILE__) -require File.expand_path('../../config/boot', __FILE__) -require 'rails/commands' +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. + +APP_PATH = File.expand_path('../../config/application', __FILE__) +require File.expand_path('../../config/boot', __FILE__) +require 'rails/commands' diff --git a/test/fixtures/comments.yml b/test/fixtures/comments.yml new file mode 100644 index 0000000..72e0400 --- /dev/null +++ b/test/fixtures/comments.yml @@ -0,0 +1,13 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + comment: MyString + user: one + site: one + + +two: + comment: MyString2 + user: two + site: one + diff --git a/test/fixtures/sites.yml b/test/fixtures/sites.yml index 0b20b0a..4ee3df4 100644 --- a/test/fixtures/sites.yml +++ b/test/fixtures/sites.yml @@ -1,13 +1,16 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - -one: - name: MyString - description: MyText - type_id: 1 - image_url: MyString - -two: - name: MyString - description: MyText - type_id: 1 - image_url: MyString +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + name: MyString + description: MyText + type: one + image_url: MyString + user: one + +two: + name: YourString + description: YourText + type: two + image_url: YourString + user: two + diff --git a/test/fixtures/trips.yml b/test/fixtures/trips.yml new file mode 100644 index 0000000..bbe6c7a --- /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 diff --git a/test/fixtures/types.yml b/test/fixtures/types.yml index 53b2c6a..49a7b4e 100644 --- a/test/fixtures/types.yml +++ b/test/fixtures/types.yml @@ -5,5 +5,8 @@ one: description: MyText two: - name: MyString - description: MyText + name: YourString + description: YourText + + +# Podriamos añadir nuevos datos de inicialización, que se referencian como # -> types(:monumento) types(:naturaleza) monumento: name: Monumento description: “Edificio o construcción de valor historico” naturaleza: name: Naturaleza description: “Lugar al aire libre de interés natural” \ No newline at end of file diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml new file mode 100644 index 0000000..fbfe998 --- /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..0cf5933 --- /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 diff --git a/test/functional/comments_controller_test.rb b/test/functional/comments_controller_test.rb new file mode 100644 index 0000000..7b16a47 --- /dev/null +++ b/test/functional/comments_controller_test.rb @@ -0,0 +1,56 @@ +require 'test_helper' + +class CommentsControllerTest < ActionController::TestCase + setup do + @comment = comments(:one) + @update = { # @update: parametros diferentes + :comment => 'AnotherComment', + :site_id => sites(:one).id + } + @site = @comment.site + @user = @comment.user + sign_in @user + end + + test "should get index" do + get :index, :site_id => @comment.to_param + assert_response :success + assert_not_nil assigns(:comments) + end + + test "should get new" do + get :new, :site_id => @comment.to_param + assert_response :success + end + + test "should create comment" do + assert_difference('Comment.count') do + post :create, comment: @update + end + + assert_redirected_to @site + end + + test "should show comment" do + get :show, id: @comment + assert_response :success + end + + test "should get edit" do + get :edit, id: @comment + assert_response :success + end + + test "should update comment" do + put :update, id: @comment, comment: @update + assert_redirected_to @site + end + + test "should destroy comment" do + assert_difference('Comment.count', -1) do + delete :destroy, id: @comment + end + + assert_redirected_to @site + end +end diff --git a/test/functional/planet_controller_test.rb b/test/functional/planet_controller_test.rb index 88229e0..cdc5356 100644 --- a/test/functional/planet_controller_test.rb +++ b/test/functional/planet_controller_test.rb @@ -1,14 +1,36 @@ -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 author" do + get :author + # Invoca “get” en acción “author” + assert_response :success # código HTTP: “200 OK” + end + + test "should get ejemplo" do + get :ejemplo + # Invoca “get” en acción “ejemplo” + assert_response :success # código HTTP: “200 OK” + end + + test "should get search" do + get :search, :search => 'X' + # Invoca “get” en acción “ejemplo” con búsqueda errónea + assert_response :success # código HTTP: “200 OK” + + get :search, :search => 'Correcta' + # Invoca “get” en acción “ejemplo” con búsqueda correcta + assert_response :success # código HTTP: “200 OK” + end +end diff --git a/test/functional/planet_controller_test.rb~ b/test/functional/planet_controller_test.rb~ new file mode 100644 index 0000000..31a0509 --- /dev/null +++ b/test/functional/planet_controller_test.rb~ @@ -0,0 +1,36 @@ +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 author" do + get :author + # Invoca “get” en acción “author” + assert_response :success # código HTTP: “200 OK” + end + + test "should get ejemplo" do + get :ejemplo + # Invoca “get” en acción “ejemplo” + assert_response :success # código HTTP: “200 OK” + end + + test "should get search" do + get :search, :search => 'X'.to_param + # Invoca “get” en acción “ejemplo” con búsqueda errónea + assert_response :success # código HTTP: “200 OK” + + get :search, :search => 'Correcta'.to_param + # Invoca “get” en acción “ejemplo” con búsqueda correcta + assert_response :success # código HTTP: “200 OK” + end +end diff --git a/test/functional/sites_controller_test.rb b/test/functional/sites_controller_test.rb index beac6d1..aa5865c 100644 --- a/test/functional/sites_controller_test.rb +++ b/test/functional/sites_controller_test.rb @@ -1,49 +1,56 @@ -require 'test_helper' - -class SitesControllerTest < ActionController::TestCase - setup do - @site = sites(:one) - 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: @site.attributes - 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: @site.attributes - 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 +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..eb6f095 --- /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..fa3eff6 100644 --- a/test/functional/types_controller_test.rb +++ b/test/functional/types_controller_test.rb @@ -1,49 +1,55 @@ -require 'test_helper' - -class TypesControllerTest < ActionController::TestCase - setup do - @type = types(:one) - end - - test "should get index" do - get :index - assert_response :success - assert_not_nil assigns(:types) - end - - test "should get new" do - get :new - assert_response :success - end - - test "should create type" do - assert_difference('Type.count') do - post :create, type: @type.attributes - end - - assert_redirected_to type_path(assigns(:type)) - end - - test "should show type" do - get :show, id: @type - assert_response :success - end - - test "should get edit" do - get :edit, id: @type - assert_response :success - end - - test "should update type" do - put :update, id: @type, type: @type.attributes - assert_redirected_to type_path(assigns(:type)) - end - - test "should destroy type" do - assert_difference('Type.count', -1) do - delete :destroy, id: @type - end - - assert_redirected_to types_path - end -end +require 'test_helper' + +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 + get :index + assert_response :success + assert_not_nil assigns(:types) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create type" do + assert_difference('Type.count') do + post :create, type: @update + end + + assert_redirected_to type_path(assigns(:type)) + end + + test "should show type" do + get :show, id: @type + assert_response :success + end + + test "should get edit" do + get :edit, id: @type + assert_response :success + end + + test "should update type" do + put :update, id: @type, type: @update + assert_redirected_to type_path(assigns(:type)) + end + + test "should destroy type" do + assert_difference('Type.count', -1) do + delete :destroy, id: @type + end + + assert_redirected_to types_path + end +end diff --git a/test/functional/visits_controller_test.rb b/test/functional/visits_controller_test.rb new file mode 100644 index 0000000..4453dcb --- /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/performance/browsing_test.rb b/test/performance/browsing_test.rb index 3fea27b..d93cdda 100644 --- a/test/performance/browsing_test.rb +++ b/test/performance/browsing_test.rb @@ -1,12 +1,12 @@ -require 'test_helper' -require 'rails/performance_test_help' - -class BrowsingTest < ActionDispatch::PerformanceTest - # Refer to the documentation for all available options - # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory] - # :output => 'tmp/performance', :formats => [:flat] } - - def test_homepage - get '/' - end -end +require 'test_helper' +require 'rails/performance_test_help' + +class BrowsingTest < ActionDispatch::PerformanceTest + # Refer to the documentation for all available options + # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory] + # :output => 'tmp/performance', :formats => [:flat] } + + def test_homepage + get '/' + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 8bf1192..3bf88c0 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,13 +1,18 @@ -ENV["RAILS_ENV"] = "test" -require File.expand_path('../../config/environment', __FILE__) -require 'rails/test_help' - -class ActiveSupport::TestCase - # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. - # - # Note: You'll currently still have to declare fixtures explicitly in integration tests - # -- they do not yet inherit this setting - fixtures :all - - # Add more helper methods to be used by all tests here... -end +ENV["RAILS_ENV"] = "test" +require File.expand_path('../../config/environment', __FILE__) +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. + # + # Note: You'll currently still have to declare fixtures explicitly in integration tests + # -- they do not yet inherit this setting + fixtures :all + + + # Add more helper methods to be used by all tests here... +end + +ActionController::TestCase.class_eval do + include Devise::TestHelpers +end diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb new file mode 100644 index 0000000..b6d6131 --- /dev/null +++ b/test/unit/comment_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CommentTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/unit/helpers/comments_helper_test.rb b/test/unit/helpers/comments_helper_test.rb new file mode 100644 index 0000000..2518c16 --- /dev/null +++ b/test/unit/helpers/comments_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class CommentsHelperTest < ActionView::TestCase +end diff --git a/test/unit/helpers/planet_controller_test.rb b/test/unit/helpers/planet_controller_test.rb new file mode 100644 index 0000000..8ca34e8 --- /dev/null +++ b/test/unit/helpers/planet_controller_test.rb @@ -0,0 +1,17 @@ +require 'test_helper' +# Rails genera estos tests automaticamente. +# +# Prueban que devuelve correctamente las páginas index y contact +# +class PlanetControllerTest < ActionController::TestCase +test "should get author" do +get :author +# Invoca “get” en acción “author” +assert_response :success # código HTTP: “200 OK” +end +test "should get ejemplo" do +get :ejemplo +# Invoca “get” en acción “ejemplo” +assert_response :success # código HTTP: “200 OK” +end +end diff --git a/test/unit/helpers/planet_controller_test.rb~ b/test/unit/helpers/planet_controller_test.rb~ new file mode 100644 index 0000000..2d2d3ba --- /dev/null +++ b/test/unit/helpers/planet_controller_test.rb~ @@ -0,0 +1,17 @@ +require 'test_helper' +# Rails genera estos tests automaticamente. +# +# Prueban que devuelve correctamente las páginas index y contact +# +class PlanetControllerTest < ActionController::TestCase +test "should get index" do +get :index +# Invoca “get” en acción “index” +assert_response :success # código HTTP: “200 OK” +end +test "should get contact" do +get :contact +# Invoca “get” en acción “contact” +assert_response :success # código HTTP: “200 OK” +end +end diff --git a/test/unit/helpers/planet_helper_test.rb b/test/unit/helpers/planet_helper_test.rb index b4082e5..930192d 100644 --- a/test/unit/helpers/planet_helper_test.rb +++ b/test/unit/helpers/planet_helper_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' - -class PlanetHelperTest < ActionView::TestCase -end +require 'test_helper' + +class PlanetHelperTest < ActionView::TestCase +end diff --git a/test/unit/helpers/sites_helper_test.rb b/test/unit/helpers/sites_helper_test.rb index 0e92edf..73170b4 100644 --- a/test/unit/helpers/sites_helper_test.rb +++ b/test/unit/helpers/sites_helper_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' - -class SitesHelperTest < ActionView::TestCase -end +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/types_helper_test.rb b/test/unit/helpers/types_helper_test.rb index 5484466..1e0f758 100644 --- a/test/unit/helpers/types_helper_test.rb +++ b/test/unit/helpers/types_helper_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' - -class TypesHelperTest < ActionView::TestCase -end +require 'test_helper' + +class TypesHelperTest < 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 index 38c8dd0..e457320 100644 --- a/test/unit/site_test.rb +++ b/test/unit/site_test.rb @@ -1,7 +1,17 @@ -require 'test_helper' - -class SiteTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end +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 validación 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 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..c33e6ac 100644 --- a/test/unit/type_test.rb +++ b/test/unit/type_test.rb @@ -1,7 +1,15 @@ -require 'test_helper' - -class TypeTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end +require 'test_helper' + +class TypeTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # 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 validación no pasa + assert type.errors[:name].any? + assert type.errors[:description].any? + end +end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb new file mode 100644 index 0000000..543db34 --- /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