class AuthorsController < ApplicationController
layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_user!, :only => [:index, :show, :edit, :update]
+ before_filter :authenticate_user!, :only => [:index, :show, :new, :create, :edit, :update]
+ before_filter :authenticate_author, :only => [:index, :show, :edit, :update]
before_filter :authenticate_admin!, :only => [:list, :browse]
def index
end
def browse
- @author = Author.find(params[:id])
+ @au = Author.find(params[:id])
respond_to do |format|
format.html { render layout: 'system' }
end
end
+ def new
+ @au = Author.new
+ @au.supply_default
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.js
+ format.json { render json: @au.to_json(Author.show_json_opt) }
+ end
+ end
+
def edit
@au = Author.edit(params[:id], @author)
end
+ def create
+ @au = Author.new()
+ @au.supply_default
+ @au.attributes = params[:author]
+ @au.overwrite @user.id
+ respond_to do |format|
+ if @au.save
+ format.html { redirect_to @au, notice: 'Author was successfully created.' }
+ format.json { render json: @au.to_json(Author.show_json_opt), status: :created, location: @artist }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @au.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
def update
@au = Author.edit(params[:id], @author)
@au.attributes = params[:author]
- @au.overwrite
+ @au.overwrite @user.id
respond_to do |format|
if @au.save