1 class SpeachBalloonsController < ApplicationController
2 before_filter :authenticate_author!, :except => [:index]
8 bl = ft[:border_limit].to_i
9 tl = ft[:tail_limit].to_i
10 if bl * tl == ft[:balloon_templates_attributes].size
18 ft[:balloon_templates_attributes].each do |k, t|
19 flag[t[:border].to_i - 1][t[:tail].to_i - 1] = nil
21 if flag.flatten.compact.size == 0
23 res = "invalid variation"
26 res = "invalid template size"
31 public # GET /speach_balloons
32 # GET /speach_balloons.json
34 @speach_balloons = SpeachBalloon.all
36 respond_to do |format|
37 format.html # index.html.erb
38 format.json { render json: @speach_balloons }
42 # GET /speach_balloons/1
43 # GET /speach_balloons/1.json
45 @speach_balloon = SpeachBalloon.find(params[:id], include: {:balloon_templates => :speach_templates})
47 respond_to do |format|
48 format.html # show.html.erb
50 render :json => @speach_balloon.to_json(include: {
51 :balloon_templates => {:include => :speach_templates}
55 render :json => "callback(" + @speach_balloon.to_json(include: {
56 :balloon_templates => {:include => :speach_templates}
62 # GET /speach_balloons/new
63 # GET /speach_balloons/new.json
65 @speach_balloon = SpeachBalloon.new
67 respond_to do |format|
68 format.html # new.html.erb
69 format.json { render json: @speach_balloon }
73 # GET /speach_balloons/1/edit
75 @speach_balloon = SpeachBalloon.find(params[:id])
78 # POST /speach_balloons
79 # POST /speach_balloons.json
81 @speach_balloon = SpeachBalloon.new(params[:speach_balloon])
83 if em = validate_param(params[:speach_balloon])
84 respond_to do |format|
85 format.json { render json: em, status: :unprocessable_entity }
88 respond_to do |format|
89 if @speach_balloon.save
90 format.html { redirect_to @speach_balloon, notice: 'Speach balloon was successfully created.' }
91 format.json { render json: @speach_balloon, status: :created, location: @speach_balloon }
93 format.html { render action: "new" }
94 format.json { render json: @speach_balloon.errors, status: :unprocessable_entity }
100 # PUT /speach_balloons/1
101 # PUT /speach_balloons/1.json
103 @speach_balloon = SpeachBalloon.find(params[:id])
105 respond_to do |format|
106 if @speach_balloon.update_attributes(params[:speach_balloon])
107 format.html { redirect_to @speach_balloon, notice: 'Speach balloon was successfully updated.' }
108 format.json { head :ok }
110 format.html { render action: "edit" }
111 format.json { render json: @speach_balloon.errors, status: :unprocessable_entity }
116 # DELETE /speach_balloons/1
117 # DELETE /speach_balloons/1.json
119 @speach_balloon = SpeachBalloon.find(params[:id])
120 @speach_balloon.destroy
122 respond_to do |format|
123 format.html { redirect_to speach_balloons_url }
124 format.json { head :ok }