<%= notice %>
<%= alert %>
+<%= notice %>
<%= alert %>
<%= yield %>diff --git a/Gemfile b/Gemfile index b0be4dd..36747b1 100644 --- a/Gemfile +++ b/Gemfile @@ -5,14 +5,7 @@ gem 'rails', '3.2.2' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' -group :development do - gem 'sqlite3' -end - -group :production do - gem 'pg' -end - +gem 'sqlite3' gem 'devise' diff --git a/Gemfile.lock b/Gemfile.lock index 3b96e7c..6247569 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,12 +62,12 @@ GEM 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) + paperclip (3.0.2) + activemodel (>= 3.0.0) + activerecord (>= 3.0.0) + activesupport (>= 3.0.0) cocaine (>= 0.0.2) mime-types - pg (0.13.2) polyglot (0.3.3) rack (1.4.1) rack-cache (1.2) @@ -125,7 +125,6 @@ DEPENDENCIES devise jquery-rails paperclip - pg rails (= 3.2.2) sass-rails (~> 3.2.3) sqlite3 diff --git a/app/assets/images/auto1.jpeg b/app/assets/images/auto1.jpeg new file mode 100644 index 0000000..9d0c91e Binary files /dev/null and b/app/assets/images/auto1.jpeg differ diff --git a/app/assets/images/auto2.jpg b/app/assets/images/auto2.jpg new file mode 100644 index 0000000..da21cb9 Binary files /dev/null and b/app/assets/images/auto2.jpg differ diff --git a/app/assets/images/beachflag.png b/app/assets/images/beachflag.png new file mode 100644 index 0000000..6e6ad4e Binary files /dev/null and b/app/assets/images/beachflag.png differ diff --git a/app/assets/images/coliseo.png b/app/assets/images/coliseo.png new file mode 100644 index 0000000..c63097e Binary files /dev/null and b/app/assets/images/coliseo.png differ diff --git a/app/assets/javascripts/comentarios.js.coffee b/app/assets/javascripts/comentarios.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/comentarios.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 50d53e3..8689609 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -12,3 +12,12 @@ *= require cleditor *= require_tree . */ + + +#container{} +#enla1{} +#enla1 a{color:blue;} +#cuerpo{} + + + diff --git a/app/assets/stylesheets/author.css.scss b/app/assets/stylesheets/author.css.scss new file mode 100644 index 0000000..d2d9d7e --- /dev/null +++ b/app/assets/stylesheets/author.css.scss @@ -0,0 +1,4 @@ +#espa{background-color:green;color:green;} +.autor1{} +#espacio{background-color:blue;color:blue;} +.autor2{} diff --git a/app/assets/stylesheets/comentarios.css.scss b/app/assets/stylesheets/comentarios.css.scss new file mode 100644 index 0000000..494c101 --- /dev/null +++ b/app/assets/stylesheets/comentarios.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the comentarios 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 ead053a..c6334b0 100644 --- a/app/assets/stylesheets/planet.css +++ b/app/assets/stylesheets/planet.css @@ -161,9 +161,3 @@ font-weight: bold; margin-right: 2em; } - - -#main .visitas { - text-indent: 70%; -} - diff --git a/app/assets/stylesheets/sites.css.scss b/app/assets/stylesheets/sites.css.scss index 682e55c..1aacaa7 100644 --- a/app/assets/stylesheets/sites.css.scss +++ b/app/assets/stylesheets/sites.css.scss @@ -1,3 +1,6 @@ // 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/ + +#comentarios a{font-weight:bold;color:red;} + diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e8065d9..089a1f8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,5 @@ +# Controlador de la aplicacion. +# class ApplicationController < ActionController::Base protect_from_forgery end diff --git a/app/controllers/comentarios_controller.rb b/app/controllers/comentarios_controller.rb new file mode 100644 index 0000000..b1f46bb --- /dev/null +++ b/app/controllers/comentarios_controller.rb @@ -0,0 +1,87 @@ +# Controlador de los comentarios donde se definen sus metodos +# +class ComentariosController < ApplicationController + +before_filter :authenticate_user! + + # GET /comentarios + # GET /comentarios.json + def index + @comentarios = Comentario.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @comentarios } + end + end + + # GET /comentarios/1 + # GET /comentarios/1.json + def show + @comentario = Comentario.find(params[:id]) + respond_to do |format| + format.html # show.html.erb + format.json { render json: @comentario } + end + end + + # GET /comentarios/new + # GET /comentarios/new.json + def new + @comentario = Comentario.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @comentario } + end + end + + # GET /comentarios/1/edit + def edit + @comentario = Comentario.find(params[:id]) + end + + # POST /comentarios + # POST /comentarios.json + def create + @comentario = Comentario.new(params[:comentario]) + + respond_to do |format| + if @comentario.save + format.html { redirect_to @comentario, notice: 'Comentario was successfully created.' } + format.json { render json: @comentario, status: :created, location: @comentario } + else + format.html { render action: "new" } + format.json { render json: @comentario.errors, status: :unprocessable_entity } + end + end + end + + # PUT /comentarios/1 + # PUT /comentarios/1.json + def update + @comentario = Comentario.find(params[:id]) + + respond_to do |format| + if @comentario.update_attributes(params[:comentario]) + format.html { redirect_to @comentario, notice: 'Comentario was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @comentario.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /comentarios/1 + # DELETE /comentarios/1.json + def destroy + @comentario = Comentario.find(params[:id]) + @comentario.destroy + + respond_to do |format| + format.html { redirect_to comentarios_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/planet_controller.rb b/app/controllers/planet_controller.rb index a8636bd..5fe3d1d 100644 --- a/app/controllers/planet_controller.rb +++ b/app/controllers/planet_controller.rb @@ -29,5 +29,17 @@ def contact # 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 realiza la busqueda de sitios y viajes + def search + if params[:q].length >= 3 + @sites = Site.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%") + @trips = Trip.where("name like ? OR description like ?", "%#{params[:q]}%", "%#{params[:q]}%") + else + render action: "busquedaincorrecta" + end + end + end diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index 57e0611..18a06b9 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -1,9 +1,12 @@ +# Controlador de los sitios donde se definen sus metodos +# 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 - + after_filter :count_visita, :only => :show + + # GET /sites # GET /sites.json def index @@ -17,12 +20,21 @@ def index format.json { render json: @sites } end end + # GET + # GET /sites.json + def id + @sites = Visit.find(params[:user_id]).sites # path: /types/id/sites + 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]) - + @comentarios = @site.comentarios respond_to do |format| format.html # show.html.erb format.json { render json: @site } @@ -88,8 +100,8 @@ def destroy format.json { head :no_content } end end - - private +private + #Incrementa visita cuando se accede al sitio def count_visita @site.increment!(:visitas) end diff --git a/app/controllers/trips_controller.rb b/app/controllers/trips_controller.rb index 321f6e3..82a9d00 100644 --- a/app/controllers/trips_controller.rb +++ b/app/controllers/trips_controller.rb @@ -1,3 +1,5 @@ +# Controlador de los viajes donde se definen sus metodos +# class TripsController < ApplicationController # authenticate_user! ejecuta acción solo si sesión existe diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rb index da826f4..62c5386 100644 --- a/app/controllers/types_controller.rb +++ b/app/controllers/types_controller.rb @@ -1,4 +1,17 @@ +# Controlador de los tipos donde se definen sus metodos +# class TypesController < ApplicationController + + # GET /types/ordered_index + # GET /types.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 # GET /types.json def index diff --git a/app/controllers/visits_controller.rb b/app/controllers/visits_controller.rb index 5bd5366..d15a0c0 100644 --- a/app/controllers/visits_controller.rb +++ b/app/controllers/visits_controller.rb @@ -1,3 +1,5 @@ +# Controlador de las visitas donde se definen sus metodos +# class VisitsController < ApplicationController # GET /visits # GET /visits.json @@ -45,7 +47,6 @@ def create 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" } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..fb8e690 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,4 @@ +# Helper de la clase Application +# module ApplicationHelper end diff --git a/app/helpers/comentarios_helper.rb b/app/helpers/comentarios_helper.rb new file mode 100644 index 0000000..020d33a --- /dev/null +++ b/app/helpers/comentarios_helper.rb @@ -0,0 +1,4 @@ +# Helper de la clase Comentarios +# +module ComentariosHelper +end diff --git a/app/helpers/planet_helper.rb b/app/helpers/planet_helper.rb index 5bbc197..3e30c2d 100644 --- a/app/helpers/planet_helper.rb +++ b/app/helpers/planet_helper.rb @@ -1,2 +1,4 @@ +# Helper de la clase Planet +# module PlanetHelper end diff --git a/app/helpers/sites_helper.rb b/app/helpers/sites_helper.rb index 621069d..e532277 100644 --- a/app/helpers/sites_helper.rb +++ b/app/helpers/sites_helper.rb @@ -1,2 +1,3 @@ +# Helper de la clase Sites module SitesHelper end diff --git a/app/helpers/trips_helper.rb b/app/helpers/trips_helper.rb index 04f333d..45b8bd1 100644 --- a/app/helpers/trips_helper.rb +++ b/app/helpers/trips_helper.rb @@ -1,2 +1,4 @@ +# Helper de la clase Trips +# module TripsHelper end diff --git a/app/helpers/types_helper.rb b/app/helpers/types_helper.rb index 40a2b9e..2189db9 100644 --- a/app/helpers/types_helper.rb +++ b/app/helpers/types_helper.rb @@ -1,2 +1,4 @@ +# Helper de la clase Types +# module TypesHelper end diff --git a/app/helpers/visits_helper.rb b/app/helpers/visits_helper.rb index 8ce5f83..8f7335f 100644 --- a/app/helpers/visits_helper.rb +++ b/app/helpers/visits_helper.rb @@ -1,2 +1,4 @@ +# Helper de la clase Visit +# module VisitsHelper end diff --git a/app/models/comentario.rb b/app/models/comentario.rb new file mode 100644 index 0000000..aa9018c --- /dev/null +++ b/app/models/comentario.rb @@ -0,0 +1,11 @@ +# Se definen las relaciones de la clase Comentario +# +class Comentario < ActiveRecord::Base +belongs_to :user +belongs_to :site + +validates :coment, :site_id, :user_id, :length => {:maximum => 240}, :presence => true +# Debe estar protegido para evitar accesos indeseados + #attr_protected :user_id + +end diff --git a/app/models/site.rb b/app/models/site.rb index 2b2f99a..9d64122 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -1,8 +1,11 @@ +# Se definen las relaciones de la clase Site +# class Site < ActiveRecord::Base belongs_to :type belongs_to :user has_many :visits - has_many :trips, :through => :visits + has_many :trips, :through => :visits + has_many :comentarios has_attached_file :image @@ -10,5 +13,5 @@ class Site < ActiveRecord::Base attr_protected :user_id # Se añaden estas definiciones - validates :name, :type_id, :presence => true # campo obligatorio + validates :name, :type_id, :presence => true # campo obligatorio end diff --git a/app/models/trip.rb b/app/models/trip.rb index 4ff6d83..c1b10cb 100644 --- a/app/models/trip.rb +++ b/app/models/trip.rb @@ -1,3 +1,5 @@ +# Se definen las relaciones de la clase Trip +# class Trip < ActiveRecord::Base belongs_to :user has_many :visits diff --git a/app/models/type.rb b/app/models/type.rb index 2284d1f..46025f9 100644 --- a/app/models/type.rb +++ b/app/models/type.rb @@ -1,3 +1,5 @@ +# Se definen las relaciones de la clase Type +# class Type < ActiveRecord::Base has_many :sites diff --git a/app/models/user.rb b/app/models/user.rb index 35b8159..b6c080d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,7 +1,17 @@ +# Se definen las relaciones de la clase User +# class User < ActiveRecord::Base + # Include default devise modules. Others available are: + # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable + devise :database_authenticatable, :registerable, + :recoverable, :rememberable, :trackable, :validatable + + # Setup accessible (or protected) attributes for your model + attr_accessible :email, :password, :password_confirmation, :remember_me has_many :sites has_many :trips + has_many :comentarios # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable diff --git a/app/models/visit.rb b/app/models/visit.rb index 57546da..d0d7e0f 100644 --- a/app/models/visit.rb +++ b/app/models/visit.rb @@ -1,3 +1,5 @@ +# Se definen las relaciones de la clase Visit +# class Visit < ActiveRecord::Base belongs_to :trip belongs_to :site diff --git a/app/views/comentarios/_form.html.erb b/app/views/comentarios/_form.html.erb new file mode 100644 index 0000000..59a35a4 --- /dev/null +++ b/app/views/comentarios/_form.html.erb @@ -0,0 +1,29 @@ +<%= form_for(@comentario) do |f| %> + <% if @comentario.errors.any? %> +
| Coment | +User | +Site | ++ | + | + |
|---|---|---|---|---|---|
| <%= comentario.coment %> | +<%= comentario.user.name %> | +<%= comentario.site.name %> | +<%= link_to 'Show', comentario %> | + <% if comentario.user == current_user %> +<%= link_to 'Edit', edit_comentario_path(comentario) %> | +<%= link_to 'Destroy', comentario, confirm: 'Are you sure?', method: :delete %> | + <% end %> +
<%= notice %>
+ ++ Coment: + <%= @comentario.coment %> +
+ ++ User: + <%= @comentario.user_id %> +
+ ++ Site: + <%= @comentario.site_id %> +
+ + +<%= link_to 'Edit', edit_comentario_path(@comentario) %> | +<%= link_to 'Back', comentarios_path %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e4c9e36..ada4bd3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -6,7 +6,11 @@ <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> - + @@ -14,7 +18,18 @@