Class: Saasaparilla::Admin::PlansController

Inherits:
ApplicationController
  • Object
show all
Includes:
Authentication::InstanceMethods, Authorization::InstanceMethods
Defined in:
app/controllers/saasaparilla/admin/plans_controller.rb

Instance Method Summary collapse

Methods included from Authorization::InstanceMethods

included

Methods included from Authentication::InstanceMethods

included, #require_current_billable

Instance Method Details

#createObject

POST /plans POST /plans.xml



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/saasaparilla/admin/plans_controller.rb', line 46

def create
  @plan = Plan.new(params[:plan])

  respond_to do |format|
    if @plan.save
      format.html { redirect_to(admin_plans_path, :notice => 'Plan was successfully created.') }
      format.xml  { render :xml => @plan, :status => :created, :location => @plan }
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @plan.errors, :status => :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /plans/1 DELETE /plans/1.xml



78
79
80
81
82
83
84
85
86
# File 'app/controllers/saasaparilla/admin/plans_controller.rb', line 78

def destroy
  @plan = Plan.find(params[:id])
  @plan.destroy

  respond_to do |format|
    format.html { redirect_to(admin_plans_url) }
    format.xml  { head :ok }
  end
end

#editObject

GET /plans/1/edit



40
41
42
# File 'app/controllers/saasaparilla/admin/plans_controller.rb', line 40

def edit
  @plan = Plan.find(params[:id])
end

#indexObject

GET /plans GET /plans.xml



8
9
10
11
12
13
14
15
# File 'app/controllers/saasaparilla/admin/plans_controller.rb', line 8

def index
  @plans = Plan.all

  respond_to do |format|
    format.html # index.html.erb
    format.xml  { render :xml => @plans }
  end
end

#newObject

GET /plans/new GET /plans/new.xml



30
31
32
33
34
35
36
37
# File 'app/controllers/saasaparilla/admin/plans_controller.rb', line 30

def new
  @plan = Plan.new

  respond_to do |format|
    format.html # new.html.erb
    format.xml  { render :xml => @plan }
  end
end

#showObject

GET /plans/1 GET /plans/1.xml



19
20
21
22
23
24
25
26
# File 'app/controllers/saasaparilla/admin/plans_controller.rb', line 19

def show
  @plan = Plan.find(params[:id])

  respond_to do |format|
    format.html # show.html.erb
    format.xml  { render :xml => @plan }
  end
end

#updateObject

PUT /plans/1 PUT /plans/1.xml



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'app/controllers/saasaparilla/admin/plans_controller.rb', line 62

def update
  @plan = Plan.find(params[:id])

  respond_to do |format|
    if @plan.update_attributes(params[:plan])
      format.html { redirect_to(admin_plans_path, :notice => 'Plan was successfully updated.') }
      format.xml  { head :ok }
    else
      format.html { render :action => "edit" }
      format.xml  { render :xml => @plan.errors, :status => :unprocessable_entity }
    end
  end
end