responders gem'i ile gelen en.yml dosyasında update/alert ve create/alert için mesajlar commentlenmiş durumda, o yüzden aşağıdaki gibi bir flash.en.yml dosyası oluşturulup projenin config/locales/ dizinine kopyalanır.
en:
flash:
actions:| FILE_TO_DOWNLOAD=`ssh [email protected] 'ls -Art /tmp/dir |tail -n 1'` | |
| scp [email protected]:/tmp/dir/${FILE_TO_DOWNLOAD} . |
| class Dashboard::Payments::CardsController < ::Dashboard::Payments::BaseController | |
| self.responder = Core::CustomServiceResponder | |
| respond_to :html | |
| before_action :customer_required | |
| def destroy | |
| service = Payments::Stripe::DeleteCreditCard.new(current_user) | |
| status_object = service.call(params[:identifier]) |
| class Core::DeleteApp < Core::ServiceBase | |
| attr_reader :user, :app | |
| def initialize(user, app) | |
| @user = user | |
| @app = app | |
| end | |
| # Her service object'te sadece bir tane public method var o da `call` methodu. | |
| # `call` methodu bir status object dondurur, bu status object `Error` veya `Success` status object olsun. |
| <iframe src="https://player.vimeo.com/video/37382619" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> <p><a href="https://vimeo.com/37382619">Dark Secrets - Hacking Team commercial</a> from <a href="https://vimeo.com/waveaudio">Wave Audio</a> on <a href="https://vimeo.com">Vimeo</a>.</p> |
| module AuthHelperMethods | |
| # Call callback_url method from inside another class as below: | |
| # | |
| # AuthHelperMethods.callback_url('a', 'b', 1) | |
| # | |
| def callback_url(base_url, provider, app_id) | |
| [base_url, "/members/auth/#{provider}/callback/#{app_id}"].join | |
| end |
| # In order to make this script work, gemfury gem needs | |
| # to be added to my_gem.gemspec as development dependency. | |
| cd ~/Projects/my_gem | |
| gem bump --version patch --push && bundle exec rake build && bundle exec fury push pkg/`ls -tr pkg |tail -1` --as user |
| module MyModule | |
| # This responder can be used with service objects. | |
| # | |
| # result = MyService.new.call | |
| # respond_with result, location: -> { payments_cards_path } | |
| # | |
| # Assumption: When we call the service, we get a status/response object which responds to `success?` method. | |
| # If response is successful, then the response object also responds to `data` method. If response is a | |
| # failure, the response object responds to `error` method. |
| module MyModule | |
| class CustomResponder < ActionController::Responder | |
| include Responders::FlashResponder | |
| include Responders::HttpCacheResponder | |
| def has_errors? | |
| case controller.action_name | |
| when 'destroy' | |
| resource.destroyed? ? false : true | |
| else |