vanities 0.1.1 → 0.1.2
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.
- data/README.rdoc +18 -1
- data/Rakefile +1 -1
- data/lib/generators/vanities/templates/vanities_controller.rb +12 -2
- data/vanities.gemspec +3 -4
- metadata +4 -16
data/README.rdoc
CHANGED
@@ -74,6 +74,17 @@ Finally, do:
|
|
74
74
|
|
75
75
|
And you're all set!
|
76
76
|
|
77
|
+
=== A word about routes...
|
78
|
+
|
79
|
+
Vanities should be set as the absolute last route in your routes.rb file. The reason
|
80
|
+
is because Rails' routing system is set up to take the first route in the file (from the top)
|
81
|
+
that matches, and stop there. If a vanity URL that doesn't exist is higher in routing
|
82
|
+
priority than, say, a user's show action, things are going to be a little funky.
|
83
|
+
|
84
|
+
All you need to do is cut and paste the route installed for the vanities controller
|
85
|
+
from wherever it is in your routes.rb file after installation, and move it to be the
|
86
|
+
last route in your system.
|
87
|
+
|
77
88
|
== Using vanities
|
78
89
|
|
79
90
|
Every model that has a call to 'has_vanity' will have a vanity object associated with it.
|
@@ -89,4 +100,10 @@ console. This would be as simple as:
|
|
89
100
|
u.vanity = Vanity.new(:name => "leeroy")
|
90
101
|
|
91
102
|
Finally, you can go to http://localhost:3000/leeroy to be automatically redirected
|
92
|
-
to the user's 'show' action.
|
103
|
+
to the user's 'show' action.
|
104
|
+
|
105
|
+
== Changelog
|
106
|
+
|
107
|
+
20 March 2011: Slight refactor to make the vanities controller render a 404 if it can't
|
108
|
+
find a vanity object. Small documentation update about routes (make sure vanities is
|
109
|
+
the LAST route in your routes.rb file).
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('vanities', '0.1.
|
5
|
+
Echoe.new('vanities', '0.1.2') do |x|
|
6
6
|
x.description = "Give each of your models a simple 'vanity' URL.
|
7
7
|
Makes example.com/users/1 into something like example.com/foobar"
|
8
8
|
x.url = "https://github.com/jaustinhughey/vanities"
|
@@ -1,8 +1,18 @@
|
|
1
1
|
class VanitiesController < ApplicationController
|
2
|
+
|
2
3
|
def show
|
3
|
-
v = Vanity.find_by_name params[:vname]
|
4
|
-
redirect_to v.vain
|
5
4
|
# Note that in this case, any model using the vanities system
|
6
5
|
# MUST be set up via REST.
|
6
|
+
|
7
|
+
if(v = Vanity.find_by_name(params[:vname]))
|
8
|
+
redirect_to v.vain
|
9
|
+
else
|
10
|
+
# If the vanity name can't be found, render a 404
|
11
|
+
respond_to do |f|
|
12
|
+
f.html { render :status => :not_found, :file => File.join(Rails.root, "public", "404.html") }
|
13
|
+
f.xml { head :not_found }
|
14
|
+
f.any { head :not_found }
|
15
|
+
end
|
16
|
+
end
|
7
17
|
end
|
8
18
|
end
|
data/vanities.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{vanities}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["J. Austin Hughey"]
|
9
|
-
s.date = %q{
|
9
|
+
s.date = %q{2011-03-20}
|
10
10
|
s.description = %q{Give each of your models a simple 'vanity' URL.
|
11
11
|
Makes example.com/users/1 into something like example.com/foobar}
|
12
12
|
s.email = %q{jaustinhughey@gmail.com}
|
@@ -16,11 +16,10 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Vanities", "--main", "README.rdoc"]
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
s.rubyforge_project = %q{vanities}
|
19
|
-
s.rubygems_version = %q{1.
|
19
|
+
s.rubygems_version = %q{1.6.0}
|
20
20
|
s.summary = %q{Give each of your models a simple 'vanity' URL. Makes example.com/users/1 into something like example.com/foobar}
|
21
21
|
|
22
22
|
if s.respond_to? :specification_version then
|
23
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
23
|
s.specification_version = 3
|
25
24
|
|
26
25
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vanities
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 1
|
10
|
-
version: 0.1.1
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.2
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- J. Austin Hughey
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date:
|
13
|
+
date: 2011-03-20 00:00:00 -06:00
|
19
14
|
default_executable:
|
20
15
|
dependencies: []
|
21
16
|
|
@@ -65,24 +60,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
60
|
requirements:
|
66
61
|
- - ">="
|
67
62
|
- !ruby/object:Gem::Version
|
68
|
-
hash: 3
|
69
|
-
segments:
|
70
|
-
- 0
|
71
63
|
version: "0"
|
72
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
65
|
none: false
|
74
66
|
requirements:
|
75
67
|
- - ">="
|
76
68
|
- !ruby/object:Gem::Version
|
77
|
-
hash: 11
|
78
|
-
segments:
|
79
|
-
- 1
|
80
|
-
- 2
|
81
69
|
version: "1.2"
|
82
70
|
requirements: []
|
83
71
|
|
84
72
|
rubyforge_project: vanities
|
85
|
-
rubygems_version: 1.
|
73
|
+
rubygems_version: 1.6.0
|
86
74
|
signing_key:
|
87
75
|
specification_version: 3
|
88
76
|
summary: Give each of your models a simple 'vanity' URL. Makes example.com/users/1 into something like example.com/foobar
|