mirror of
https://github.com/danbee/danbarberphoto
synced 2025-03-04 08:49:07 +00:00
General cleanup
This commit is contained in:
parent
069df5965b
commit
3165baf2fc
@ -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
|
||||
|
||||
@ -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"))
|
||||
|
||||
@ -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
|
||||
|
||||
@ -18,6 +18,7 @@ class SessionsController < ApplicationController
|
||||
|
||||
def destroy
|
||||
sign_out
|
||||
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user