trestle_generator 1.1.0 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/templates/routes.rb +6 -3
  2. metadata +42 -78
data/templates/routes.rb CHANGED
@@ -1,11 +1,14 @@
1
1
  ActionController::Routing::Routes.draw do |map|
2
- # Add your own custom routes here.
3
2
  # The priority is based upon order of creation: first created -> highest priority.
4
-
5
- # Here's a sample route:
3
+
4
+ # Sample of regular route:
6
5
  # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
7
6
  # Keep in mind you can assign values other than :controller and :action
8
7
 
8
+ # Sample of named route:
9
+ # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
10
+ # This route can be invoked with purchase_url(:id => product.id)
11
+
9
12
  # You can have the root of your site routed by hooking up ''
10
13
  # -- just remember to delete public/index.html.
11
14
  # map.connect '', :controller => "welcome"
metadata CHANGED
@@ -1,102 +1,66 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.10
2
+ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: trestle_generator
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.1.0
7
- date: 2006-03-14
8
- summary: "[Rails] A drop-in replacement for the scaffold generator that produces
9
- production-ready controllers that are safe from state-changing HTTP GET requests
10
- and that have streamlined URLs."
6
+ version: 1.1.2
7
+ date: 2006-04-18 00:00:00 -05:00
8
+ summary: "[Rails] A drop-in replacement for the scaffold generator that produces production-ready controllers that are safe from state-changing HTTP GET requests and that have streamlined URLs."
11
9
  require_paths:
12
- - templates
10
+ - templates
13
11
  email: nils@alumni.rice.edu
14
- homepage: http://www.rubyforge.org/projects/trestle
12
+ homepage: http://trestle.rubyforge.org/
15
13
  rubyforge_project: trestle
16
- description: "Don�t drive your train across a gorge with nothing but a scaffold underneath it.
17
- Use a trestle instead! The trestle generator is drop-in replacement for the
18
- Rails scaffold generator. Unlike scaffolding, trestle controllers protect your
19
- models from state-changing HTTP GET requests. They also have streamlined URLs
20
- that make your application more usable. SAFETY The trestle generator requires
21
- the HTTP POST method for actions that change data. Well-behaved web applications
22
- protect themselves against errant HTTP GET requests such as come from Google Web
23
- Accelerator and the like. Scaffolded controllers fail to do this. USABILITY
24
- Trestle controllers have just five actions (list, new, show, edit, and destroy).
25
- The scaffold generator produces controllers that have eight actions. Fewer
26
- actions exposed to the outside world is better if the behavior of these actions
27
- is in line with the semantics of HTTP GET and HTTP POST. The net effect of this
28
- design improvement is that you will not have to throw away or tweak as much
29
- trestle-generated code as you do scaffold-generated code. Less work for you
30
- means your application gets built sooner. Tobias L�tke�s postback_generator
31
- RubyGem had the same idea, but trestle goes further. A scaffold for a database
32
- table named �people� has the following HTTP interface: /people - Lists existing
33
- person records /people/list - Lists existing person records /people/new -
34
- Shows an empty person form /people/create - Creates a new person record from
35
- request parameters /people/show/99 - Shows the person record having ID 99
36
- /people/edit/99 - Shows a person form for the person record having ID 99
37
- /people/update/99 - Updates the person record having ID 99 using request
38
- parameters /people/destroy/99 - Deletes the person record having ID 99, even
39
- for HTTP GET! Contrast this with the HTTP interface of the equivalent trestle
40
- controller: /people - GET or POST lists existing person records /people/new -
41
- GET shows an empty person form /people/new - POST creates a new person record
42
- from request parameters /people/99 - GET or POST shows the person record having
43
- ID 99 /people/99/edit - GET shows a person form for the person record having ID
44
- 99 /people/99/edit - POST updates the person record having ID 99 using request
45
- parameters /people/99/destroy - GET redirects to /people/99/edit with a notice
46
- that the user must click the form�s Destroy button in order to destroy a record
47
- /people/99/destroy - POST deletes the person record having ID 99 after prompting
48
- the user for confirmation Notice the hierarchical nature of trestle URLs.
49
- Because the ID comes before the verb, the user can click the Up One Level button
50
- on the Google Toolbar to explore the application. (The Up One Level button clips
51
- one element off the end of the current URL.) Scaffold URLs do not play nicely
52
- with the Up One Level button. Trestle controllers are pain relief to users who
53
- like the Up One Level button. But for a user who likes to type URLs in by hand,
54
- it also shows a friendly notice if his request is missing an ID. This is one
55
- more way to improve usability."
14
+ description: "============================================================================ Trestle Generator ============================================================================ A drop-in replacement for Ruby on Rails\x92s scaffold generator Everybody loves scaffolding, and with good reason. It\x92s the feature of the Ruby on Rails framework that makes a database table editable on the web in mere seconds, and with just a few lines of generated Ruby code. The trestle generator is drop-in replacement for the Rails scaffold generator. It produces scaffolding that\x92s more like production-quality code while maintaining all the rapid goodness you know and love about Rails. Don\x92t drive your train across a gorge with nothing but a scaffold underneath it. Use a trestle instead! Trestles have two advantages over scaffolds: * Better handling of HTTP POST and GET requests * A streamlined URL structure that makes your application easier to use Downloading and installation is a breeze with RubyGems, the package manager that\x92s included in most Ruby distributions. Just type the following at a command line: gem install trestle_generator Generating trestles for your database tables is also a one-step process: script/generate trestle YourModelNameHere ---------------------------------------------------------------------------- Why switch from scaffolds to trestles? SAFETY ---------------------------------------------------------------------------- The trestle generator produces Rails views that use HTTP POST to request changes (instead of GET). It also generates Rails controllers that execute such changes only for HTTP POST requests. Well-behaved web applications must protect user data against unwanted changes, including those arising from errant HTTP GET requests such as Google Web Accelerator is known to make. The scaffolding provided by Rails v1.1 is better about this than Rails v1.0 was, but trestles solve the problem of GET vs POST more cleanly and comprehensively. ---------------------------------------------------------------------------- Why switch from scaffolds to trestles? USABILITY ---------------------------------------------------------------------------- Trestle controllers have just four actions (index, new, edit, and destroy). Contrast this with scaffold controllers which have eight actions to implement the same functionality. This is mostly a matter of taste, but Rails developers appreciate more than most that \x93less is more.\x94 Just as important as aesthetics is the fact that trestle controllers better reflect GET and POST semantics, making for more intelligible HTTP conversations in your applications. (Apparently, Tobias L\xFCtke wrote a postback_generator RubyGem with a similar philosophy, but trestles take the concept further.) Use trestles instead of scaffolding and you will find yourself throwing away and tweaking less code as you build out applications. As joyous as Ruby programming is, less code is still a good thing. Let\x92s look at some of the differences between trestles and scaffolds. A scaffold for a database table named \x91people\x92 has the following HTTP interface: URL Result ============================================================================ /people Lists existing person records /people/list ---------------------------------------------------------------------------- /people/new Shows an empty person form ---------------------------------------------------------------------------- /people/create Creates a new person record from request parameters ---------------------------------------------------------------------------- /people/show/99 Shows the person record having ID 99 ---------------------------------------------------------------------------- /people/edit/99 Shows a person form for the person record having ID 99 ---------------------------------------------------------------------------- /people/update/99 Updates the person record having ID 99 using request parameters ---------------------------------------------------------------------------- /people/destroy/99 Deletes the person record having ID 99 As of Rails v1.1, scaffold controllers reject requests to insert, update and delete records if the request is HTTP GET instead of POST. This is a safety improvement, but the design still leaves something to be desired. Contrast this with the HTTP interface of the equivalent trestle controller: URL HTTP Method Result ============================================================================ /people GET or POST Lists existing person records ---------------------------------------------------------------------------- /people/new GET Shows an empty person form POST Creates a new person record from request parameters ---------------------------------------------------------------------------- /people/99 GET or POST Shows the person record having ID 99 ---------------------------------------------------------------------------- /people/99/edit GET Shows a person form for the person record having ID 99 POST Updates the person record having ID 99 using request parameters ---------------------------------------------------------------------------- /people/99/destroy GET Redirects to /people/99/edit with a notice that the user must click the form\x92s Destroy button in order to destroy a record POST Deletes the person record having ID 99 after prompting the user for confirmation A trestle degrades gracefully if the user has JavaScript turned off. And the hierarchical nature of trestle URLs, wherein the ID comes before the verb, lets the user click the Up One Level button on the Google Toolbar to explore the application. (The Up One Level button clips one element off the end of the current URL.) Scaffold URLs do not play nicely with the Up One Level button. The trestle interface is not just pain relief for users without JavaScript and those who like the Up One Level button. If you type URLs by hand, you get a friendly notice\x97\x97instead of a Rails exception\x97\x97if a request is missing an ID. There is simply less opportunity for error. That\x92s a tried-and-true way to up the usability factor. Do yourself and your users a favor by switching from scaffolds to trestles. Visit the RubyForge page (http://trestle.rubyforge.org/) for this open-source project. Contact me at nils@alumni.rice.edu. -- //. _/. Nils Jonsson"
56
15
  autorequire:
57
16
  default_executable:
58
17
  bindir: bin
59
18
  has_rdoc: false
60
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
61
20
  requirements:
62
- -
63
- - ">"
64
- - !ruby/object:Gem::Version
65
- version: 0.0.0
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
66
24
  version:
67
25
  platform: ruby
26
+ signing_key:
27
+ cert_chain:
68
28
  authors:
69
- - Nils Jonsson
29
+ - Nils Jonsson
70
30
  files:
71
- - trestle_generator.rb
72
- - USAGE
73
- - templates/controller.rb
74
- - templates/form.rhtml
75
- - templates/form_trestle.rhtml
76
- - templates/functional_test.rb
77
- - templates/helper.rb
78
- - templates/layout.rhtml
79
- - templates/routes.rb
80
- - templates/style.css
81
- - templates/view_edit.rhtml
82
- - templates/view_list.rhtml
83
- - templates/view_new.rhtml
84
- - templates/view_show.rhtml
31
+ - trestle_generator.rb
32
+ - USAGE
33
+ - templates/controller.rb
34
+ - templates/form.rhtml
35
+ - templates/form_trestle.rhtml
36
+ - templates/functional_test.rb
37
+ - templates/helper.rb
38
+ - templates/layout.rhtml
39
+ - templates/routes.rb
40
+ - templates/style.css
41
+ - templates/view_edit.rhtml
42
+ - templates/view_list.rhtml
43
+ - templates/view_new.rhtml
44
+ - templates/view_show.rhtml
85
45
  test_files: []
46
+
86
47
  rdoc_options: []
48
+
87
49
  extra_rdoc_files: []
50
+
88
51
  executables: []
52
+
89
53
  extensions: []
54
+
90
55
  requirements:
91
- - Ruby on Rails v1.0.0
56
+ - Ruby on Rails v1.0.0 or later
92
57
  dependencies:
93
- - !ruby/object:Gem::Dependency
94
- name: rails
95
- version_requirement:
96
- version_requirements: !ruby/object:Gem::Version::Requirement
97
- requirements:
98
- -
99
- - ">="
100
- - !ruby/object:Gem::Version
101
- version: 1.0.0
102
- version:
58
+ - !ruby/object:Gem::Dependency
59
+ name: rails
60
+ version_requirement:
61
+ version_requirements: !ruby/object:Gem::Version::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 1.0.0
66
+ version: