Sha256: 1e93854bef9d979b801b99702e87622497da3be592c3ce32ab48cdeb3f1a036b
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
module Notifiable class DeviceTokensController < Notifiable.api_controller_class before_filter :ensure_current_notifiable_user, :only => :destroy def create @device_token = DeviceToken.find_or_create_by(:token => params[:token]) @device_token.provider = params[:provider] @device_token.user_id = current_notifiable_user.id if current_notifiable_user if @device_token.save head :status => :ok else render :json => { :errors => @device_token.errors.full_messages }, :status => :internal_server_error end end def destroy @device_token = DeviceToken.where(:token => params[:token]).first if !@device_token head :status => :not_found elsif !@device_token.user.eql?(current_notifiable_user) head :status => :unauthorized elsif @device_token.destroy head :status => :ok else render :json => { :errors => @device_token.errors.full_messages }, :status => :internal_server_error end end private def ensure_current_notifiable_user head :status => :not_acceptable unless current_notifiable_user end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
notifiable-rails-0.1.1 | app/controllers/notifiable/device_tokens_controller.rb |
notifiable-rails-0.1.0 | app/controllers/notifiable/device_tokens_controller.rb |