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:
create:
notice: '%{resource_name} was successfully created.'
alert: '%{resource_name} could not be created.'
update:
notice: '%{resource_name} was successfully updated.'
alert: '%{resource_name} could not be updated.'
destroy:
notice: '%{resource_name} was successfully destroyed.'
alert: '%{resource_name} could not be destroyed.'
anodes:
create:
notice: "Custom create message."
alert: "Custom creation failed message!"
destroy:
notice: "Custom destroy notice message."
alert: "Custom alert message"Örnek bir controller aşağıdaki gibidir:
class Admin::FeedsController < ApplicationController
responders :flash # Bu olmazsa flash mesajlar set edilmez!
respond_to :html
def index
@feeds = Feed.includes([:app]).id_desc.page(params[:page])
respond_with @feeds
end
def create
@feed = Feed.new(feed_params)
@feed.save
respond_with(:admin, @feed)
end
def update
@feed.update(feed_params)
respond_with(:admin, @feed)
end
def destroy
@feed.destroy
respond_with(:admin, @feed)
end
endrespond_with [:members, @member], location: -> { members_profile_path }Custom responder kullanmak icin ilgili controller asagidaki gibi olmali:
class Payments::CardsController < ApplicationController
self.responder = MyModule::CustomServiceResponder
respond_to :html
end