1
0
mirror of https://github.com/danbee/danbarberphoto synced 2025-03-04 08:49:07 +00:00

General cleanup

This commit is contained in:
Daniel Barber 2018-02-16 11:10:13 -05:00
parent 069df5965b
commit 3165baf2fc
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
6 changed files with 15 additions and 20 deletions

View File

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

View File

@ -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"))

View File

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

View File

@ -18,6 +18,7 @@ class SessionsController < ApplicationController
def destroy
sign_out
redirect_to root_path
end

View File

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

View File

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