75 lines
1004 B
Ruby
75 lines
1004 B
Ruby
class Admin::QuotesController < ApplicationController
|
|
layout "admin"
|
|
|
|
before_filter :auth_admin
|
|
|
|
def index
|
|
|
|
@quotes = Quote.all
|
|
end
|
|
|
|
|
|
def show
|
|
@quote = Quote.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
def new
|
|
@quote = Quote.new(:enabled => true)
|
|
|
|
end
|
|
|
|
def edit
|
|
@quote = Quote.find(params[:id])
|
|
|
|
end
|
|
|
|
def create
|
|
@quote = Quote.new(quote_params)
|
|
|
|
if @quote.save
|
|
@quotes = Quote.all
|
|
|
|
else
|
|
render :action => "new"
|
|
end
|
|
end
|
|
|
|
def update
|
|
@quote = Quote.find(params[:id])
|
|
|
|
|
|
if params[:quote]
|
|
if @quote.update_attributes(quote_params)
|
|
|
|
|
|
else
|
|
render :action => "edit"
|
|
end
|
|
|
|
elsif params[:tag_id]
|
|
@quote.tag_by_tag_ids(params[:tag_id])
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
@quote = Quote.find(params[:id])
|
|
|
|
@quote.destroy
|
|
|
|
end
|
|
|
|
private
|
|
def quote_params
|
|
params.require(:quote).permit(:quote, :author, :tags_cache, :enabled)
|
|
end
|
|
|
|
|
|
|
|
end
|