Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Customizable parameter name in routing.
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Nickolas  
View profile  
 More options Oct 6 2012, 7:19 am
From: Nickolas <sir.nicko...@gmail.com>
Date: Sat, 6 Oct 2012 04:19:13 -0700 (PDT)
Local: Sat, Oct 6 2012 7:19 am
Subject: Customizable parameter name in routing.

There is a function "resources" in the class "SingletonResource" that
provides 7 routes for an indicated resource, like this:
GET /photos
GET /photos/:id
etc.

Also, there are some gems(as "friendly_id") that give a possibility to
store an arbitrary string in :id parameter, what helps to have frendlier
links like /photos/big-ben.

But for several reasons this approach makes me feel odd. The fact that in
the :id is stored, for example, a name of a model is not quite elegant. And
also it leads to such code in controller:

@photo = Photo.find_by_name(params[:id])

Which can be hardy called beautiful. "params[:name]" should fit much
better. To avoid this, the gem mentioned above redefines the "find" method
in choosen model, but I do not like it too. It can easily provoke gem
conflicts, because there is a lot of gems that do it too. E.g., commonly a
gem which adds "soft delete" also redefines this method that makes
impossible to use them together or can break functionality somehow later.

So, my suggestion is to add a :param_name option to "resources" method so
we can have the behavior like this:

resources :photos, :param_name => 'name'

GET /photos/:name

Could it be useful if I add such feature? In addition, there is a whole
bunch of questions on stackoveflow with the same desire.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.