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" @page_title = "Portfolio"
@num_blank = 4 - @categories.length @num_blank = 4 - @categories.length
respond_to do |format|
format.html # index.html.erb
format.xml { render xml: @categories }
end
end end
# GET /categories/1 # GET /categories/1
# GET /categories/1.xml # GET /categories/1.xml
def show def show
@category = Category.find(params[:id]) @category = Category.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render xml: @category }
end
end end
end end

View File

@ -6,6 +6,7 @@ class ContactsController < ApplicationController
def create def create
@contact = Contact.new(params[:contact]) @contact = Contact.new(params[:contact])
if @contact.valid? if @contact.valid?
Notifier.contact_notification(@contact).deliver Notifier.contact_notification(@contact).deliver
redirect_to(:new_contact, notice: t("contact.thanks")) redirect_to(:new_contact, notice: t("contact.thanks"))

View File

@ -7,24 +7,25 @@ class PhotosController < ApplicationController
end end
@num_blank = 11 - @photos.length @num_blank = 11 - @photos.length
respond_to do |format|
format.html
end
end end
private private
def for_category(category_id) def for_category(category_id)
@category = Category.find_by_id(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 @page_title = @category.name
end end
def all def all
@photos = Photo.enabled.order(taken_at: :desc) @photos = Photo.enabled
.page(params[:page]) .order(taken_at: :desc)
.page(params[:page])
@page_title = "All Photos" @page_title = "All Photos"
end end
end end

View File

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

View File

@ -1,6 +1,7 @@
class ViewsController < ApplicationController class ViewsController < ApplicationController
def create def create
photo = Photo.find_by_id(params[:photo_id]) photo = Photo.find_by_id(params[:photo_id])
if photo.present? if photo.present?
photo.log_view photo.log_view
head :ok head :ok

View File

@ -1,7 +1,8 @@
class Category < ActiveRecord::Base class Category < ActiveRecord::Base
has_and_belongs_to_many :photos 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 slug :slug, from: :name