class Admin::PhotosController < ApplicationController layout "admin" before_filter :auth_admin def index @photos = Photo.all end def show @photo = Photo.find(params[:id]) end def new @photo = Photo.new end def edit @photo = Photo.find(params[:id]) end def create @photo = Photo.new(:image =>params[:files]) if @photo.save @photos = Photo.all else render :action => "new" end end def update @photo = Photo.find(params[:id]) if params[:photo] if @photo.update_attributes(photo_params) else render :action => "edit" end elsif params[:tag_id] @photo.tag_by_tag_ids(params[:tag_id]) end end def destroy @photo = Photo.find(params[:id]) @photo.destroy end private def photo_params params.require(:photo).permit(:title, :description, :tags_cache) end end