Module: MuckEngine::FlashErrors
- Defined in:
- lib/muck_engine/flash_errors.rb
Instance Method Summary collapse
-
#output_errors(title, options = {}, fields = nil, flash_only = false) ⇒ Object
Output flash and object errors.
-
#output_flash(options = {}) ⇒ Object
Output only flash errors.
Instance Method Details
#output_errors(title, options = {}, fields = nil, flash_only = false) ⇒ Object
Output flash and object errors
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/muck_engine/flash_errors.rb', line 10 def output_errors(title, = {}, fields = nil, flash_only = false) fields = [fields] unless fields.is_a?(Array) flash_html = render(:partial => 'shared/flash_messages') flash.clear css_class = "class=\"#{[:class] || 'error'}\"" unless [:class].nil? field_errors = render(:partial => 'shared/field_error', :collection => fields) if flash_only || (!flash_html.empty? && field_errors.empty?) # Only flash. Don't render errors for any fields render(:partial => 'shared/flash_error_box', :locals => {:flash_html => flash_html, :css_class => css_class}) elsif !field_errors.empty? # Field errors and/or flash render(:partial => 'shared/error_box', :locals => {:title => title, :flash_html => flash_html, :field_errors => field_errors, :css_class => css_class, :extra_html => [:extra_html]}) else #nothing '' end end |
#output_flash(options = {}) ⇒ Object
Output only flash errors
5 6 7 |
# File 'lib/muck_engine/flash_errors.rb', line 5 def output_flash( = {}) output_errors('', , nil, true) end |