dejavu 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +15 -0
  2. data/lib/dejavu.rb +8 -1
  3. data/lib/dejavu/version.rb +1 -1
  4. metadata +9 -9
data/README.md CHANGED
@@ -78,6 +78,21 @@ This will assume you have a `Product` class which has a `:has_one` association
78
78
  to a `Price` class.
79
79
 
80
80
 
81
+ Excluding some errors
82
+ ---------------------
83
+
84
+ When using dejavu with a registration form, for example, you might find
85
+ yourself in the need of avoid some errors in the model. For example, if the
86
+ form is to create a new user and you're using Devise, you problably want to
87
+ exclude the `:password` field to be reconstructed. Otherwise the form will
88
+ always show an error saying "Password can't be blank".
89
+
90
+ To fix this kind of situations, you can use `get_dejavu_for` this way:
91
+
92
+ = form_for get_dejavu_for(@user, :exclude_errors_on => :password) do |f|
93
+
94
+ This will remove all possible errors in the `:password` field.
95
+
81
96
 
82
97
  Final notes
83
98
  ===========
data/lib/dejavu.rb CHANGED
@@ -7,7 +7,7 @@ module Dejavu
7
7
  !!flash[:"saved_#{obj_name}_for_redisplay"]
8
8
  end
9
9
 
10
- def get_dejavu_for(obj)
10
+ def get_dejavu_for(obj, opts = {})
11
11
  is_instance = ActiveRecord::Base === obj
12
12
  model_name = is_instance ? obj.class.model_name.underscore : obj.to_s
13
13
 
@@ -23,6 +23,13 @@ module Dejavu
23
23
  obj.to_s.classify.constantize.new flash[:"saved_#{model_name}_for_redisplay"]
24
24
  end
25
25
  foo.valid?
26
+
27
+ if opts[:exclude_errors_on]
28
+ [opts[:exclude_errors_on]].flatten.each do |attr|
29
+ foo.errors.delete(attr)
30
+ end
31
+ end
32
+
26
33
  foo
27
34
  else
28
35
  is_instance ? obj : obj.to_s.classify.constantize.new
@@ -1,3 +1,3 @@
1
1
  module Dejavu
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dejavu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &79731040 !ruby/object:Gem::Requirement
16
+ requirement: &79465570 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *79731040
24
+ version_requirements: *79465570
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec-rails
27
- requirement: &79730230 !ruby/object:Gem::Requirement
27
+ requirement: &79499400 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.7'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *79730230
35
+ version_requirements: *79499400
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: capybara
38
- requirement: &79728920 !ruby/object:Gem::Requirement
38
+ requirement: &79498830 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 1.1.1
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *79728920
46
+ version_requirements: *79498830
47
47
  description: Remember your object after a redirect
48
48
  email:
49
49
  - roger@itnig.net
@@ -139,7 +139,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
139
139
  version: '0'
140
140
  segments:
141
141
  - 0
142
- hash: -399023693
142
+ hash: 139276129
143
143
  required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  none: false
145
145
  requirements:
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  segments:
150
150
  - 0
151
- hash: -399023693
151
+ hash: 139276129
152
152
  requirements: []
153
153
  rubyforge_project:
154
154
  rubygems_version: 1.8.15