1 class SpeachBalloonsController < ApplicationController
2 before_filter :authenticate_author!, :only => [:index, :show]
3 before_filter :authenticate_admin!, :only => [:list, :browse, :create, :update, :destroy]
9 bl = ft[:size_count].to_i
10 tl = ft[:tail_count].to_i
11 if bl * tl == ft[:balloon_templates_attributes].size
19 ft[:balloon_templates_attributes].each do |k, t|
20 flag[t[:size].to_i - 1][t[:tail].to_i - 1] = nil
22 if flag.flatten.compact.size == 0
24 res = "invalid variation"
27 res = "invalid template size"
33 # GET /speach_balloons
34 # GET /speach_balloons.json
36 @speach_balloons = SpeachBalloon.all
38 respond_to do |format|
39 format.html # index.html.erb
40 format.json { render json: @speach_balloons }
44 # GET /speach_balloons/1
45 # GET /speach_balloons/1.json
47 @speach_balloon = SpeachBalloon.find(params[:id], include: {:balloon_templates => :speach_templates})
49 respond_to do |format|
50 format.html # show.html.erb
52 render :json => @speach_balloon.to_json(include: {
53 :balloon_templates => {:include => :speach_templates}
57 render :json => "callback(" + @speach_balloon.to_json(include: {
58 :balloon_templates => {:include => :speach_templates}
65 @speach_balloons = SpeachBalloon.all
67 respond_to do |format|
68 format.html { render layout: 'system' }
69 format.json { render json: @speach_balloons }
74 @speach_balloon = SpeachBalloon.find(params[:id])
76 respond_to do |format|
77 format.html { render layout: 'system' }
78 format.json { render json: @speach_balloon }
82 # POST /speach_balloons
83 # POST /speach_balloons.json
85 @speach_balloon = SpeachBalloon.new(params[:speach_balloon])
86 if em = validate_param(params[:speach_balloon])
87 respond_to do |format|
88 format.json { render json: em, status: :unprocessable_entity }
91 respond_to do |format|
92 if @speach_balloon.save
93 format.html { redirect_to @speach_balloon, notice: 'Speach balloon was successfully created.' }
94 format.json { render json: @speach_balloon, status: :created, location: @speach_balloon }
96 format.html { render action: "new" }
97 format.json { render json: @speach_balloon.errors, status: :unprocessable_entity }
103 # PUT /speach_balloons/1
104 # PUT /speach_balloons/1.json
106 @speach_balloon = SpeachBalloon.find(params[:id])
108 respond_to do |format|
109 if @speach_balloon.update_attributes(params[:speach_balloon])
110 format.html { redirect_to @speach_balloon, notice: 'Speach balloon was successfully updated.' }
111 format.json { head :ok }
113 format.html { render action: "edit" }
114 format.json { render json: @speach_balloon.errors, status: :unprocessable_entity }
119 # DELETE /speach_balloons/1
120 # DELETE /speach_balloons/1.json
122 @speach_balloon = SpeachBalloon.find(params[:id])
123 @speach_balloon.destroy
125 respond_to do |format|
126 format.html { redirect_to speach_balloons_url }
127 format.json { head :ok }