happy_path 0.0.2 → 0.0.3
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.
- checksums.yaml +8 -8
- data/README.md +23 -3
- data/lib/happy_path/version.rb +1 -1
- data/lib/happy_path.rb +7 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWUwYzk5YWRmOGJlNmU2MWU1ZDgxOWRkZmM1OTYxNTdjNGFiNjE0NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NWRiYmM0ZmFlNWUzYmNmNGU4ZWU1NzVkYjlmYTIzYTVkNDgwMzM3Ng==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWRlNjc5OGIyMDQzOTAwN2Y2ODA5YzljYWI5NDBhZDgzM2FkNzEzNjFiZTRi
|
10
|
+
NGYyOWIzOGRkMjU0ZWJjZTk5Mzc2MWIxMjhkZTRmMDI2NzczZDg0ZDhjNDYy
|
11
|
+
YWU0MDAzNGUxNDRmMDRiMmMyOGI5NjY0OTkyMWY2NzExNTdlNjg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjE3OTQ3YjJmYTExN2FkMDIyMzA5OWYxZGQ4OTA4MjhkZTA2YmVjZjdlODdj
|
14
|
+
NmQwMjlmN2U4NDYzYTJjOWNmMGJlZGE4ZTFjMmE1YTRiZTg2OGMwYmJhNmYx
|
15
|
+
Y2RlYTAzZTdhZWE2NDU1OGY1OGQ2OWIxOGYzNjE4NjZkN2M3MjM=
|
data/README.md
CHANGED
@@ -1,6 +1,24 @@
|
|
1
|
+
[](http://badge.fury.io/rb/happy_path)
|
1
2
|
# HappyPath
|
2
3
|
|
3
|
-
|
4
|
+
1. Navigate to your `posts/new` form.
|
5
|
+
2. Fill it out, hit create.
|
6
|
+
3. Go do other stuff.
|
7
|
+
4. Navigate back to your last post.
|
8
|
+
5. But wait what was the id of that post?
|
9
|
+
6. Go to command line
|
10
|
+
7. `rails c` your way into typing `Post.last.id`
|
11
|
+
8. Go to `posts/id`
|
12
|
+
9. Tedious.
|
13
|
+
|
14
|
+
With HappyPath, you can just do:
|
15
|
+
|
16
|
+
1. Navigate to your `posts/new` form.
|
17
|
+
2. Fill it out, hit create.
|
18
|
+
3. Go do other stuff.
|
19
|
+
4. Navigate back to your last post with `/posts/last`.
|
20
|
+
|
21
|
+
This is enabled for `/last` and `/first`.
|
4
22
|
|
5
23
|
## Installation
|
6
24
|
|
@@ -16,9 +34,11 @@ Or install it yourself as:
|
|
16
34
|
|
17
35
|
$ gem install happy_path
|
18
36
|
|
19
|
-
##
|
37
|
+
## How Do the Things?
|
38
|
+
|
39
|
+
After installation, put `extend HappyPath` in your `ApplicationController` and then any controllers you want this functionality to work in such as `posts_controller.rb`.
|
20
40
|
|
21
|
-
|
41
|
+
Then put `setup_happy_path` in ApplicationController, and `follow_happy_paths` in each other controller and you are good to go.
|
22
42
|
|
23
43
|
## Contributing
|
24
44
|
|
data/lib/happy_path/version.rb
CHANGED
data/lib/happy_path.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
module HappyPath
|
2
|
-
extend ActiveSupport::Concern
|
3
2
|
PATHS = ['first', 'last']
|
4
3
|
|
5
4
|
def setup_happy_path
|
6
|
-
rescue_from ActiveRecord::RecordNotFound
|
5
|
+
rescue_from ActiveRecord::RecordNotFound do |e|
|
6
|
+
class_constant = controller_name.classify.constantize
|
7
|
+
raise e unless self.respond_to?(:happy_paths) && self.respond_to?(:show) && HappyPath::PATHS.include?(params[:id]) && !class_constant.count.zero?
|
8
|
+
self.happy_paths(e, class_constant)
|
9
|
+
end
|
7
10
|
end
|
8
11
|
|
9
12
|
def follow_happy_paths
|
10
|
-
define_method (:happy_paths) do |exception|
|
11
|
-
|
12
|
-
raise exception unless self.respond_to?(:show) && HappyPath::PATHS.include?(params[:id]) && !class_constant.count.zero?
|
13
|
-
redirect_to action: :show, id: class_constant.send(params[:id]).id
|
13
|
+
define_method (:happy_paths) do |exception, class_constant|
|
14
|
+
redirect_to action: params[:action], id: class_constant.send(params[:id]).id
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: happy_path
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- danReynolds
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|