Just an update on this thread.
I now have pretty and meaningul urls of the form mysite.com/categories/
permalink
However, there are evidently some old links out there on the web that
still point at mysite.com/categories/1
These now throw an error.
Is there any way to catch any urls that still
DanC wrote in post #956986:
Just an update on this thread.
I now have pretty and meaningul urls of the form mysite.com/categories/
permalink
However, there are evidently some old links out there on the web that
still point at mysite.com/categories/1
These now throw an error.
Is there
Hi,
I am confused as to how I would modify the routes to only catch the
urls that have an integer id?
For example, I have an articles resource so my routes file contains:
map.resources :articles
And I have modified my model file with
def to_param
permalink
end
and the controller to
Please quote when replying.
DanC wrote in post #957008:
Hi,
I am confused as to how I would modify the routes to only catch the
urls that have an integer id?
Either use a regex to match the parameter (and then send it to a
different controller action) or have a single controller action that
Hi Marnen,
Either use a regex to match the parameter (and then send it to a
different controller action) or have a single controller action that
runs both find_by_permalink and find_by_id.
I have added this to the controller which seems to work well, as my
regex writing is weak.
@article
DanC wrote in post #957019:
Hi Marnen,
Either use a regex to match the parameter (and then send it to a
different controller action) or have a single controller action that
runs both find_by_permalink and find_by_id.
I have added this to the controller which seems to work well, as my
regex
Either use a regex to match the parameter (and then send it to a
different controller action) or have a single controller action that
runs both find_by_permalink and find_by_id.
I have added this to the controller which seems to work well, as my
regex writing is weak.
@article =
Seems like a job for FriendlyID.
Luke
On 2010-10-15, at 10:35 AM, tshim wrote:
I would like to modify the app to display more human urls like
/categories/category_name/services/service_name
See the relevant railscast.
--
You received this message because you are subscribed to the
Thanks guys,
I have modified things in this way
http://media.railscasts.com/videos/063_model_name_in_url.mov
Cheers,
Dan
On 16 Oct, 08:13, Luke Cowell lcow...@gmail.com wrote:
Seems like a job for FriendlyID.
Luke
On 2010-10-15, at 10:35 AM, tshim wrote:
I would like to modify the
The to_param method on your model is what gets called to generate the
ID for the URL.
So a simple solution is to just change that. Lets say your Category
model has a unique slug field. You could change it to this:
class Category
def to_param
self.slug
end
end
Then instead of finding by
I would like to modify the app to display more human urls like
/categories/category_name/services/service_name
See the relevant railscast.
--
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
11 matches
Mail list logo