1 class ComicsController < ApplicationController
2 before_filter :authenticate_author!, :except => [:index, :show, :play]
7 comic.author_id = current_author.id
20 respond_to do |format|
21 format.html # index.html.erb
22 format.json { render json: @comics }
29 @comic = Comic.find(params[:id])
31 respond_to do |format|
32 format.html # show.html.erb
33 format.json { render json: @comic }
38 @comic = Comic.find(params[:id], include: {:panels => [:panel_pictures => :resource_picture, :balloons => :speaches]}, order: 'panels.t')
40 respond_to do |format|
41 format.html # index.html.erb
43 render :json => @comic.to_json(
45 :panels => {:include => {
46 :panel_pictures => {:include => :resource_picture},
47 :balloons => {:include => :speaches}
53 render :json => "callback(" + @comic.to_json(
55 :panels => {:include => {
56 :panel_pictures => {:include => :resource_picture},
57 :balloons => {:include => :speaches}
66 # GET /comics/new.json
70 respond_to do |format|
71 format.html # new.html.erb
72 format.json { render json: @comic }
78 @comic = Comic.find(params[:id])
84 @comic = Comic.new(params[:comic])
87 respond_to do |format|
89 format.html { redirect_to @comic, notice: 'Comic was successfully created.' }
90 format.json { render json: @comic, status: :created, location: @comic }
92 format.html { render action: "new" }
93 format.json { render json: @comic.errors, status: :unprocessable_entity }
101 @comic = Comic.find(params[:id])
102 if @comic.own? current_author
103 respond_to do |format|
104 if @comic.update_attributes(params[:comic])
105 format.html { redirect_to @comic, notice: 'Comic was successfully updated.' }
106 format.json { head :ok }
108 format.html { render action: "edit" }
109 format.json { render json: @comic.errors, status: :unprocessable_entity }
113 format.html { render action: "edit" }
114 format.json { render json: @comic.errors, status: :unprocessable_entity }
119 # DELETE /comics/1.json
121 @comic = Comic.find(params[:id])
122 if @comic.own? current_author
124 respond_to do |format|
125 format.html { redirect_to comics_url }
126 format.json { head :ok }
129 format.html { render action: "edit" }
130 format.json { render json: @comic.errors, status: :unprocessable_entity }