Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11181 (closed enhancement: fixed)

Opened 1 year ago

Last modified 1 year ago

[PATCH] Custom paths for resource actions

Reported by: ivanvr Assigned to: michael@koziarski.com
Priority: normal Milestone: 2.x
Component: ActionPack Version: edge
Severity: normal Keywords: i18n l10n Verified
Cc:

Description

Following Michael Koziarski's advice, I created this patch. First time I do this, so I hope I did everything right.

Patch contains very small changes, so I hope it can get committed.

Basically, what this patch adds is the ability to change default action paths for "new" and "edit", in an environment or directly in the route definition (because on some languages, coherent action names would depend on the resource name):

config.action_controller.resources_path_names = { :new => 'nuevo', :edit => 'editar' }

In the route definition:

map.resource :schools, :as => 'escuelas', :path_names => { :new => 'nueva' }

You could argue action names refer to a "record" (so it wouldn't be gender dependent) as opposed to the resource name. I would argue it would look weird in a URL, like seeing the words "her penis".

Attachments

custom_paths_for_default_resource_actions.diff (3.0 kB) - added by ivanvr on 02/20/08 22:24:01.
custom_paths_for_default_resource_actions-2.diff (3.8 kB) - added by ivanvr on 04/09/08 22:59:56.
Updated for r9245 and added documentation.
custom_paths_for_resource_actions.diff (4.2 kB) - added by ivanvr on 04/14/08 23:05:53.
Updated to allow renaming of :new and :collection actions too.

Change History

02/20/08 22:24:01 changed by ivanvr

  • attachment custom_paths_for_default_resource_actions.diff added.

02/20/08 22:26:14 changed by ivanvr

I forgot to mention, all tests pass on r8915, and I added a little test, but I don't know how to test this patch more thouroughly. Any ideas?

02/22/08 10:07:42 changed by afernasa

+ 1

03/15/08 21:02:45 changed by david

  • owner changed from core to michael@koziarski.com.

03/25/08 10:21:10 changed by jeanmartin

+1 that's kind of what I need. There is a plugin called "Custom Resource Name" (http://www.nomedojogo.com/custom-resource-name-plugin/) but it only allows you to translate action names once, so there can't be different translations of "new" for two different resources.

04/09/08 22:59:56 changed by ivanvr

  • attachment custom_paths_for_default_resource_actions-2.diff added.

Updated for r9245 and added documentation.

04/11/08 16:30:13 changed by nwiger

+1

04/11/08 16:59:01 changed by ivanvr

  • keywords changed from i18n l10n to i18n l10n Verified.

Finally, a third supporter!

04/12/08 00:57:43 changed by nzkoz

  • status changed from new to closed.
  • resolution set to fixed.

04/14/08 23:05:53 changed by ivanvr

  • attachment custom_paths_for_resource_actions.diff added.

Updated to allow renaming of :new and :collection actions too.

04/14/08 23:11:04 changed by ivanvr

  • status changed from closed to reopened.
  • resolution deleted.
  • summary changed from [PATCH] Custom paths for default resource actions to [PATCH] Custom paths for resource actions.

I updated this patch so now we're able to rename the :new and :collection resource actions.

04/14/08 23:12:42 changed by ivanvr

By the way, this latest patch applies to latest git (at the time of this writing).

04/14/08 23:19:47 changed by ivanvr

I just found the lighthouse for rails, should I put this over there?

04/23/08 02:27:22 changed by nzkoz

  • status changed from reopened to closed.
  • resolution set to fixed.

The second patch doesn't have any additional tests, so I'm going to close this again. Open up a ticket at the rails lighthouse with the tested patch when you're ready to get it reviewed.