Class: SubscriptionsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- SubscriptionsController
- Defined in:
- app/controllers/subscriptions_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /subscriptions POST /subscriptions.json.
-
#destroy ⇒ Object
DELETE /subscriptions/1 DELETE /subscriptions/1.json.
-
#edit ⇒ Object
GET /subscriptions/1/edit.
-
#index ⇒ Object
GET /subscriptions GET /subscriptions.json.
-
#new ⇒ Object
GET /subscriptions/new GET /subscriptions/new.json.
-
#show ⇒ Object
GET /subscriptions/1 GET /subscriptions/1.json.
-
#update ⇒ Object
PUT /subscriptions/1 PUT /subscriptions/1.json.
Instance Method Details
#create ⇒ Object
POST /subscriptions POST /subscriptions.json
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/subscriptions_controller.rb', line 47 def create @subscription = Subscription.new(subscription_params) @subscription.user = current_user respond_to do |format| if @subscription.save format.html { redirect_to @subscription, notice: t('controller.successfully_created', model: t('activerecord.models.subscription')) } format.json { render json: @subscription, status: :created, location: @subscription } else format.html { render action: "new" } format.json { render json: @subscription.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /subscriptions/1 DELETE /subscriptions/1.json
79 80 81 82 83 84 85 86 |
# File 'app/controllers/subscriptions_controller.rb', line 79 def destroy @subscription.destroy respond_to do |format| format.html { redirect_to subscriptions_url } format.json { head :no_content } end end |
#edit ⇒ Object
GET /subscriptions/1/edit
42 43 |
# File 'app/controllers/subscriptions_controller.rb', line 42 def edit end |
#index ⇒ Object
GET /subscriptions GET /subscriptions.json
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/subscriptions_controller.rb', line 8 def index if @work @subscriptions = @work.subscriptions.page(params[:page]) else @subscriptions = Subscription.page(params[:page]) end respond_to do |format| format.html # index.html.erb format.json { render json: @subscriptions } end end |
#new ⇒ Object
GET /subscriptions/new GET /subscriptions/new.json
32 33 34 35 36 37 38 39 |
# File 'app/controllers/subscriptions_controller.rb', line 32 def new @subscription = Subscription.new respond_to do |format| format.html # new.html.erb format.json { render json: @subscription } end end |
#show ⇒ Object
GET /subscriptions/1 GET /subscriptions/1.json
23 24 25 26 27 28 |
# File 'app/controllers/subscriptions_controller.rb', line 23 def show respond_to do |format| format.html # show.html.erb format.json { render json: @subscription } end end |
#update ⇒ Object
PUT /subscriptions/1 PUT /subscriptions/1.json
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/controllers/subscriptions_controller.rb', line 64 def update @subscription.assign_attributes(subscription_params) respond_to do |format| if @subscription.save format.html { redirect_to @subscription, notice: t('controller.successfully_updated', model: t('activerecord.models.subscription')) } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @subscription.errors, status: :unprocessable_entity } end end end |