Class: Jackpot::CustomersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Jackpot::CustomersController
- Defined in:
- app/controllers/jackpot/customers_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /customers POST /customers.json.
-
#credit_card ⇒ Object
PUT /customers/37/credit_card Assigns a credit card to the given customer.
-
#destroy ⇒ Object
DELETE /customers/1 DELETE /customers/1.json.
-
#edit ⇒ Object
GET /customers/1/edit.
-
#index ⇒ Object
GET /customers GET /customers.json.
-
#new ⇒ Object
GET /customers/new GET /customers/new.json.
-
#show ⇒ Object
GET /customers/1 GET /customers/1.json.
-
#update ⇒ Object
PUT /customers/1 PUT /customers/1.json.
Instance Method Details
#create ⇒ Object
POST /customers POST /customers.json
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/jackpot/customers_controller.rb', line 58 def create @customer = Customer.new(params[:customer]) respond_to do |format| if @customer.save format.html { redirect_to @customer, notice: 'Customer was successfully created.' } format.json { render json: @customer, status: :created, location: @customer } else format.html { render action: "new" } format.json { render json: @customer.errors, status: :unprocessable_entity } end end end |
#credit_card ⇒ Object
PUT /customers/37/credit_card Assigns a credit card to the given customer
7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/jackpot/customers_controller.rb', line 7 def credit_card @customer = Customer.find params[:id] @customer.update_credit_card Card.new params[:credit_card] respond_to do |format| format.html { redirect_to @customer, notice: "This customer's card was successfully updated." } format.json { head :ok } end end |
#destroy ⇒ Object
DELETE /customers/1 DELETE /customers/1.json
90 91 92 93 94 95 96 97 98 |
# File 'app/controllers/jackpot/customers_controller.rb', line 90 def destroy @customer = Customer.find(params[:id]) @customer.destroy respond_to do |format| format.html { redirect_to customers_url } format.json { head :ok } end end |
#edit ⇒ Object
GET /customers/1/edit
52 53 54 |
# File 'app/controllers/jackpot/customers_controller.rb', line 52 def edit @customer = Customer.find(params[:id]) end |
#index ⇒ Object
GET /customers GET /customers.json
20 21 22 23 24 25 26 27 |
# File 'app/controllers/jackpot/customers_controller.rb', line 20 def index @customers = Customer.all respond_to do |format| format.html # index.html.erb format.json { render json: @customers } end end |
#new ⇒ Object
GET /customers/new GET /customers/new.json
42 43 44 45 46 47 48 49 |
# File 'app/controllers/jackpot/customers_controller.rb', line 42 def new @customer = Customer.new respond_to do |format| format.html # new.html.erb format.json { render json: @customer } end end |
#show ⇒ Object
GET /customers/1 GET /customers/1.json
31 32 33 34 35 36 37 38 |
# File 'app/controllers/jackpot/customers_controller.rb', line 31 def show @customer = Customer.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @customer } end end |
#update ⇒ Object
PUT /customers/1 PUT /customers/1.json
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/controllers/jackpot/customers_controller.rb', line 74 def update @customer = Customer.find(params[:id]) respond_to do |format| if @customer.update_attributes(params[:customer]) format.html { redirect_to @customer, notice: 'Customer was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @customer.errors, status: :unprocessable_entity } end end end |