diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index e565129..007c7f2 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -9,21 +9,11 @@ class CategoriesController < ApplicationController @page_title = "Portfolio" @num_blank = 4 - @categories.length - - respond_to do |format| - format.html # index.html.erb - format.xml { render xml: @categories } - end end # GET /categories/1 # GET /categories/1.xml def show @category = Category.find(params[:id]) - - respond_to do |format| - format.html # show.html.erb - format.xml { render xml: @category } - end end end diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index ff7a060..8802b59 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -6,6 +6,7 @@ class ContactsController < ApplicationController def create @contact = Contact.new(params[:contact]) + if @contact.valid? Notifier.contact_notification(@contact).deliver redirect_to(:new_contact, notice: t("contact.thanks")) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 104106f..70f0476 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -7,24 +7,25 @@ class PhotosController < ApplicationController end @num_blank = 11 - @photos.length - - respond_to do |format| - format.html - end end private def for_category(category_id) @category = Category.find_by_id(category_id) - @photos = @category.photos.enabled.order(taken_at: :desc) - .page(params[:page]) + + @photos = @category.photos.enabled + .order(taken_at: :desc) + .page(params[:page]) + @page_title = @category.name end def all - @photos = Photo.enabled.order(taken_at: :desc) - .page(params[:page]) + @photos = Photo.enabled + .order(taken_at: :desc) + .page(params[:page]) + @page_title = "All Photos" end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 7f27d79..d02fcc1 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -18,6 +18,7 @@ class SessionsController < ApplicationController def destroy sign_out + redirect_to root_path end diff --git a/app/controllers/views_controller.rb b/app/controllers/views_controller.rb index 543532d..c2a5651 100644 --- a/app/controllers/views_controller.rb +++ b/app/controllers/views_controller.rb @@ -1,6 +1,7 @@ class ViewsController < ApplicationController def create photo = Photo.find_by_id(params[:photo_id]) + if photo.present? photo.log_view head :ok diff --git a/app/models/category.rb b/app/models/category.rb index b6eaf7a..c79c907 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -1,7 +1,8 @@ class Category < ActiveRecord::Base has_and_belongs_to_many :photos - validates_presence_of :name, :slug - validates_uniqueness_of :name, :slug + + validates :name, presence: true, uniqueness: true + validates :slug, presence: true, uniqueness: true slug :slug, from: :name