Flaw in permalinking system.

Hi

Basically I have a permalink system setup using the to_param method in
the model file. Since I have a system in which categories has_many
tutorials, my URLs look a bit like this:

site.com/CatID-Category-Perma/TutID-Tutorial-Perma

I have a system to redirect when the user puts in an ID to the proper
permalink; like this:

@tutorial = Tutorial.find(params[:id])
@category = Category.find(params[:category_id])
if isNumeric(params[:id]) || isNumeric(params[:category_id])
  redirect_to tutpmlnk_path(:category_id => @tutorial.category, :id =>
@tutorial)
  return false
end

However there is still a massive problem in my permalink system; which
is if the user types in a wrong permalink it still goes to the correct
page (and counts as duplicate content). For example:
The proper URL to an example page: site.com/CatID-Category-Perm
The wrong URL that works: site.com/CatID-ANYTHING
This also works if you put the tutorial ID followed by anything.

I need to try and find a way to redirect these wrong URLs to the right
ones; I've spent hours and hours trying to figure out ways around it
but none of them seem to work. Could someone PLEASE help me with this
massive issue in my permalink system?

Please Help,

Thanks In Advance,

Joe

Just check if request.fullpath or request.path include
tutpmlnk_path(:category_id => @tutorial.category, :id =>
@tutorial) string. If so render otherwise redirect to proper path.
What do you think ? And btw ? Why is it so important ? Who visits the
wrong links ?

Robert Pankowecki

I don't know what request.path or request.fullpath are, or how to
check if they include my redirect thing (I'm a real RoR noob); but
I'll be looking around files for them.

As for why it's so important; firstly I still need to perfect the
permalink system (remove some more punctuation), and don't want people
linking wrongly (as the link they know would have been correct at the
time); secondly if google see one link I'm pretty sure they are going
to think it's duplicate content. And thirdly I want to have a sound
permalink system and overall site.

Please Help,

Thanks In Advance,

Joe

I don't know what request.path or request.fullpath are, or how to
check if they include my redirect thing (I'm a real RoR noob); but
I'll be looking around files for them.

As for why it's so important; firstly I still need to perfect the
permalink system (remove some more punctuation), and don't want people
linking wrongly (as the link they know would have been correct at the
time); secondly if google see one link I'm pretty sure they are going
to think it's duplicate content. And thirdly I want to have a sound
permalink system and overall site.

Please Help,

Thanks In Advance,

Joe

I don't know what request.path or request.fullpath are, or how to
check if they include my redirect thing (I'm a real RoR noob); but
I'll be looking around files for them.

As for why it's so important; firstly I still need to perfect the
permalink system (remove some more punctuation), and don't want people
linking wrongly (as the link they know would have been correct at the
time); secondly if google see one link I'm pretty sure they are going
to think it's duplicate content. And thirdly I want to have a sound
permalink system and overall site.

Please Help,

Thanks In Advance,

Joe

`request' is a method available in your controller. It returns
ActionDispatch::Request instance. `fullpath and `path' are method that
can be called on `request' instance.

You might wanna try friendly_id . http://ruby-toolbox.com/categories/rails_permalinks___slugs.html
It has the feature that object can be found by their historical
permalinks and redirected to the current one. Nice thing to have in
case you manipulate your permalink system.

Robert Pankowecki

Looking through all of my controllers I can't see anything about any
requests..
As for friendly URLs, I might look at it at some point; but for now is
there anyway I could just make another if statement in the controllers
to make it redirect if it has the wrong permalink? (Not only would
this mean I could easily solve the problem, but that I would get a
greater understanding of Ruby on Rails through it).

I've tried for hours and hours to try and find a solution but just
can't figure it out..

Please Help,

Thanks In Advance,

Joe

@tutorial = Tutorial.find(params[:id])
@category = Category.find(params[:category_id])
if isNumeric(params[:id]) || isNumeric(params[:category_id])
  ok_path = tutpmlnk_path(:category_id => @tutorial.category, :id =>
@tutorial)
    redirect_to ok_path unless request.fullpath.include?(ok_path) #
sth like that... Not best, bo ok for beginning.
   ...
end

`request' is a method defined in your controller superclass. Same
thing as `params'.

Robert Pankowecki