RubyGems Navigation menu

trestle_generator 1.1.0

Don’t drive your train across a gorge with nothing but a scaffold underneath it. Use a trestle instead! The trestle generator is drop-in replacement for the Rails scaffold generator. Unlike scaffolding, trestle controllers protect your models from state-changing HTTP GET requests. They also have streamlined URLs that make your application more usable. SAFETY The trestle generator requires the HTTP POST method for actions that change data. Well-behaved web applications protect themselves against errant HTTP GET requests such as come from Google Web Accelerator and the like. Scaffolded controllers fail to do this. USABILITY Trestle controllers have just five actions (list, new, show, edit, and destroy). The scaffold generator produces controllers that have eight actions. Fewer actions exposed to the outside world is better if the behavior of these actions is in line with the semantics of HTTP GET and HTTP POST. The net effect of this design improvement is that you will not have to throw away or tweak as much trestle-generated code as you do scaffold-generated code. Less work for you means your application gets built sooner. Tobias Lütke’s postback_generator RubyGem had the same idea, but trestle goes further. A scaffold for a database table named ‘people’ has the following HTTP interface: /people - Lists existing person records /people/list - Lists existing person records /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, even for HTTP GET! Contrast this with the HTTP interface of the equivalent trestle controller: /people - GET or POST lists existing person records /people/new - GET shows an empty person form /people/new - 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 /people/99/edit - 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’s Destroy button in order to destroy a record /people/99/destroy - POST deletes the person record having ID 99 after prompting the user for confirmation Notice the hierarchical nature of trestle URLs. Because the ID comes before the verb, the user can 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. Trestle controllers are pain relief to users who like the Up One Level button. But for a user who likes to type URLs in by hand, it also shows a friendly notice if his request is missing an ID. This is one more way to improve usability.

Gemfile:
=

安装:
=

版本列表:

  1. 1.1.7.3 August 17, 2006* (11.5 KB)
  2. 1.1.7.2 August 02, 2006* (11.5 KB)
  3. 1.1.7.1 July 19, 2006* (11.5 KB)
  4. 1.1.7 July 01, 2006* (11.5 KB)
  5. 1.1.6 June 26, 2006* (10.5 KB)
  6. 1.1.0 March 14, 2006* (9.5 KB)
显示所有版本 (共 13 个)

Runtime 依赖 (1):

rails >= 1.0.0

业主:

作者:

  • Nils Jonsson

SHA 256 校验和:

=

下载总量 85,149

这个版本 10,818

版本发布:

许可:

需要的 Ruby 版本: > 0.0.0

需要的 RubyGems 版本:

链接: