How can I rewrite this route?

I would like to have some more friendly URLS …

I have some routes , with parameters I would like to rewrite but I
don’t know if it’s possible :

/programs?list=1 => /short_list

/programs?list=2 => /medium_list

/programs?list=3 => /long_list

thanks for your feedback

try to make it like this:

match “programs/:id” => “Programs#your_action_name”, :as => :list

So in your controller ‘Programs’ you are able to handle the request with
the
“id” which will be variable, and the path can be called by ‘list_path’.
The
action you’ll call here will handle the request and you may then list
the
rows accordingly… :slight_smile:

On Mon, Aug 22, 2011 at 4:31 PM, Erwin [email protected] wrote:

/programs?list=3 => /long_list
http://groups.google.com/group/rubyonrails-talk?hl=en.

Please consider the environment before printing this email.

Regards,
Surya

thanks , That’s better than what I did first,

but is there any way to match to a specific name ( short_list,
medium_list, long_list ) based upon the parameter 1, 2, 3

In my opinion you should let controller handle the size of your list, if
it
is ‘programs/1’, ‘programs/2’ or ‘programs/3’ it will look for
:controller
=> programs, :action => your_defined_action . So, in there in your
action
you just need to manipulate the params[:id] and according to it generate
your data. For e.g. - if :id is 1 then generate your short_list, for 2
medium_list and for 3 long_list. Since, this all will be handle with in
one
action defined with in a controller it will be very compact and DRY, and
can
be viewed in a template. 3njoy :slight_smile:

On Mon, Aug 22, 2011 at 5:33 PM, Erwin [email protected] wrote:

don’t know if it’s possible :
You received this message because you are subscribed to the Google

[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

Please consider the environment before printing this email.

Regards,
Surya

On Aug 22, 2011, at 8:13 AM, Surya wrote:

On Mon, Aug 22, 2011 at 5:33 PM, Erwin [email protected] wrote:
thanks , That’s better than what I did first,

but is there any way to match to a specific name ( short_list,
medium_list, long_list ) based upon the parameter 1, 2, 3

I think you’re asking about this:

match ‘/short_list’ => “Programs#list”, :list_id => 1, :as =>
‘short_list’
match ‘/medium_list’ => “Programs#list”, :list_id => 2, :as =>
‘medium_list’
match ‘/long_list’ => “Programs#list”, :list_id => 3, :as =>
‘long_list’

The URL has the word and the controller gets a number as the parameter.

-Rob

Rob B.
[email protected] http://AgileConsultingLLC.com/
[email protected] http://GaslightSoftware.com/

request with the

To post to this group, send email to [email protected]
Regards,
.


You received this message because you are subscribed to the Google
Groups “Ruby on Rails: Talk” group.
To post to this group, send email to rubyonrails-
[email protected].
To unsubscribe from this group, send email to
[email protected]
.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
.

Rob B. http://agileconsultingllc.com
[email protected]
+1 513-295-4739
Skype: rob.biedenharn