Class: BootstrapAdmin::Responder
- Inherits:
-
ActionController::Responder
- Object
- ActionController::Responder
- BootstrapAdmin::Responder
- Defined in:
- lib/bootstrap_admin/responder.rb
Instance Method Summary collapse
-
#to_format ⇒ Object
Responds to any format…
-
#to_html ⇒ Object
Responds to HTML format.
Instance Method Details
#to_format ⇒ Object
Responds to any format…
5 6 7 8 9 |
# File 'lib/bootstrap_admin/responder.rb', line 5 def to_format render @format => format_resource(@resource, @format), :status => status_for_resource(@resource), :content_type => content_type_for(@format) end |
#to_html ⇒ Object
Responds to HTML format
It sets flash messages, handles search, sets pagination (@paginator)
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bootstrap_admin/responder.rb', line 15 def to_html if get? && resource.is_a?(ActiveRecord::Relation) items = process_search resource items, paginator = paginate items controller.instance_variable_set("@#{controller.controller_name}", items) controller.instance_variable_set("@paginator", paginator) if request.xhr? render controller.params[:action], layout: false end elsif resource.is_a?(ActiveRecord::Base) && (post? || put?) && resource.valid? = if post? 'helpers.messages.create.success' else #put? 'helpers.messages.update.success' end controller.flash[:success] = I18n.t(, :model => resource.class.model_name.human) redirect_to :action => :show, :id => resource.id else if delete? controller.flash[:success] = I18n.t("helpers.messages.destroy.success", :model => resource.class.model_name.human) redirect_to :action => :index else super end end end |