rails_contrib 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,9 +26,16 @@ module RailsContrib
26
26
  render :file => Rails.root.join('public', '422.html'), :status => 422, :layout => false
27
27
  end
28
28
 
29
- def redirect_with_flash(path, type, flash, params=nil)
30
- path = (params.nil? ? path : (params[:back].present? ? params[:back] : path))
31
- redirect_to path, { :flash => { type => (flash.is_a?(Array) ? flash : [flash]) } }
29
+ def redirect_with_flash(options, type, flash)
30
+ args = [options]
31
+ case flash
32
+ when String
33
+ flash = [flash]
34
+ when ActiveRecord::Base
35
+ flash = flash.errors.full_messages
36
+ end
37
+ flash = { :flash => { type => flash } }
38
+ redirect_to *(args[0].is_a?(Hash) ? args[0].merge(flash) : args.push(flash))
32
39
  end
33
40
 
34
41
  def flash_errors(source)
@@ -38,7 +45,7 @@ module RailsContrib
38
45
  flash.now[:error] << source
39
46
  when Array
40
47
  source.each { |error| flash.now[:error] << error }
41
- else
48
+ when ActiveRecord::Base
42
49
  source.errors.full_messages.each { |error| flash.now[:error] << error }
43
50
  end
44
51
  end
@@ -1,5 +1,5 @@
1
1
  module RailsContrib
2
2
 
3
- VERSION = '0.0.5'
3
+ VERSION = '0.0.6'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_contrib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-14 00:00:00.000000000 Z
12
+ date: 2013-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails