class BalloonTemplatesController < ApplicationController
- before_filter :authenticate_author!, :except => [:index]
+ before_filter :authenticate_admin!, :except => [:index]
# GET /balloon_templates
# GET /balloon_templates.json
format.json { render json: @balloon_templates }
end
end
-=begin
- # GET /balloon_templates/1
- # GET /balloon_templates/1.json
- def show
- @balloon_template = BalloonTemplate.find(params[:id])
-
- respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @balloon_template }
- end
- end
-
- # GET /balloon_templates/new
- # GET /balloon_templates/new.json
- def new
- @balloon_template = BalloonTemplate.new
-
- respond_to do |format|
- format.html # new.html.erb
- format.json { render json: @balloon_template }
- end
- end
-
- # GET /balloon_templates/1/edit
- def edit
- @balloon_template = BalloonTemplate.find(params[:id])
- end
-
- # POST /balloon_templates
- # POST /balloon_templates.json
- def create
- @balloon_template = BalloonTemplate.new(params[:balloon_template])
-
- respond_to do |format|
- if @balloon_template.save
- format.html { redirect_to @balloon_template, notice: 'Balloon template was successfully created.' }
- format.json { render json: @balloon_template, status: :created, location: @balloon_template }
- else
- format.html { render action: "new" }
- format.json { render json: @balloon_template.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # PUT /balloon_templates/1
- # PUT /balloon_templates/1.json
- def update
- @balloon_template = BalloonTemplate.find(params[:id])
-
- respond_to do |format|
- if @balloon_template.update_attributes(params[:balloon_template])
- format.html { redirect_to @balloon_template, notice: 'Balloon template was successfully updated.' }
- format.json { head :ok }
- else
- format.html { render action: "edit" }
- format.json { render json: @balloon_template.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # DELETE /balloon_templates/1
- # DELETE /balloon_templates/1.json
- def destroy
- @balloon_template = BalloonTemplate.find(params[:id])
- @balloon_template.destroy
-
- respond_to do |format|
- format.html { redirect_to balloon_templates_url }
- format.json { head :ok }
- end
- end
-=end
end
class SpeachBalloonsController < ApplicationController
- before_filter :authenticate_author!, :except => [:index]
+ before_filter :authenticate_author!, :only => [:index]
+ before_filter :authenticate_admin!, :except => [:index]
private
# POST /speach_balloons.json
def create
@speach_balloon = SpeachBalloon.new(params[:speach_balloon])
-
if em = validate_param(params[:speach_balloon])
respond_to do |format|
format.json { render json: em, status: :unprocessable_entity }
class SpeachTemplatesController < ApplicationController
- before_filter :authenticate_author!, :except => [:index]
+ before_filter :authenticate_admin!, :except => [:index]
# GET /speach_templates
# GET /speach_templates.json
end
end
-=begin
- # GET /speach_templates/1
- # GET /speach_templates/1.json
- def show
- @speach_template = SpeachTemplate.find(params[:id])
-
- respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @speach_template }
- end
- end
-
- # GET /speach_templates/new
- # GET /speach_templates/new.json
- def new
- @speach_template = SpeachTemplate.new
-
- respond_to do |format|
- format.html # new.html.erb
- format.json { render json: @speach_template }
- end
- end
-
- # GET /speach_templates/1/edit
- def edit
- @speach_template = SpeachTemplate.find(params[:id])
- end
-
- # POST /speach_templates
- # POST /speach_templates.json
- def create
- @speach_template = SpeachTemplate.new(params[:speach_template])
-
- respond_to do |format|
- if @speach_template.save
- format.html { redirect_to @speach_template, notice: 'Speach template was successfully created.' }
- format.json { render json: @speach_template, status: :created, location: @speach_template }
- else
- format.html { render action: "new" }
- format.json { render json: @speach_template.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # PUT /speach_templates/1
- # PUT /speach_templates/1.json
- def update
- @speach_template = SpeachTemplate.find(params[:id])
-
- respond_to do |format|
- if @speach_template.update_attributes(params[:speach_template])
- format.html { redirect_to @speach_template, notice: 'Speach template was successfully updated.' }
- format.json { head :ok }
- else
- format.html { render action: "edit" }
- format.json { render json: @speach_template.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # DELETE /speach_templates/1
- # DELETE /speach_templates/1.json
- def destroy
- @speach_template = SpeachTemplate.find(params[:id])
- @speach_template.destroy
-
- respond_to do |format|
- format.html { redirect_to speach_templates_url }
- format.json { head :ok }
- end
- end
-=end
end
class Admin < ActiveRecord::Base
# Include default devise modules. Others available are:
- # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
+ # , :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
- :recoverable, :rememberable, :trackable, :validatable
+ :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
+ before_save :ensure_authentication_token\r
def self.start(email, passwd)
Admin.create! :email => email, :password => passwd, :password_confirmation => passwd, :activate => 1
<h1>Listing speach_balloons</h1>
-
<table>
<tr>
<th>Name</th>
<th>Tail limit</th>
<th>Border limit</th>
<th></th>
+ <th></th>
</tr>
<% @speach_balloons.each do |speach_balloon| %>
<td><%= speach_balloon.tail_limit %></td>
<td><%= speach_balloon.border_limit %></td>
<td><%= link_to 'show', speach_balloon %></td>
+ <td>
+ <% if admin_signed_in? -%>
+ <%= link_to 'Destroy', speach_balloon, confirm: 'Are you sure?', method: :delete %>
+ <% end -%>
+ </td>
</tr>
<% end %>
</table>
- <%# current_admin.authentication_token %>
+authentication_token:<%= current_admin.authentication_token %>
match 'resource_pictures/:subdir/:id(.:format)/' => 'resource_pictures#show'
match 'home/(:action)', :controller => 'home'
match 'help/(:action)', :controller => 'help'
- controller 'system' do
- get 'start'
- get 'index'
-# match 'start', :to => 'system#start'
- end
+ match 'system/(:action)', :controller => 'system'
+# controller 'system' do
+# get 'start'
+# get 'index'
+## match 'start', :to => 'system#start'
+# end
# Sample of named route:
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
# t.encryptable
# t.confirmable
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
- # t.token_authenticatable
+ t.token_authenticatable
t.integer :activate, :null => false, :default => 0
t.timestamps
add_index :admins, :reset_password_token, :unique => true
# add_index :admins, :confirmation_token, :unique => true
# add_index :admins, :unlock_token, :unique => true
- # add_index :admins, :authentication_token, :unique => true
+ add_index :admins, :authentication_token, :unique => true
end
end
t.datetime "last_sign_in_at"\r
t.string "current_sign_in_ip"\r
t.string "last_sign_in_ip"\r
+ t.string "authentication_token"\r
t.integer "activate", :default => 0, :null => false\r
t.datetime "created_at"\r
t.datetime "updated_at"\r
end\r
\r
+ add_index "admins", ["authentication_token"], :name => "index_admins_on_authentication_token", :unique => true\r
add_index "admins", ["email"], :name => "index_admins_on_email", :unique => true\r
add_index "admins", ["reset_password_token"], :name => "index_admins_on_reset_password_token", :unique => true\r
\r