I’ve tried, but I can’t figure out how to replace $1 with a permalink
variable thats in ruby on rails. Im pretty sure regex cannot help me
with this, I need to take the permalink value, and use that in the
redirect.
PLEASE JUST TELL ME AND ILL LEARN, I DONT JUST TAKE THE ANSWER AND BE
DONE WITH IT, I LEARN FROM IT.
Top-posting and yelling – not a particularly appealing combination…
Sure, you can manually enter rewrite rules for every one of your
tutorials and categories, and avoid using regular expressions. Be
my guest.
Or you can start with the simplest example above, and figure out how
a simple regex can give you “12” from “/tutorials/12”. Write a method
to take that value “12” and return “12-test9”. Put that in a rewrite
rule.
Try it with a couple of other values. Works? Good. Start on the next
most complex string. Lather, rinse, repeat.
So, I can’t just pass it my permalink value (which is worked out using
to_param)? I have to create a whole method using regex that returns
something that is exactly the same?
Please Help,
I would GREATLY appreciate it if you could just give a reply like “If
I had a blog with the same kind of setup, what I could do is write a
redirect like this, as you can get the permalink value by doing this.”
So, I can’t just pass it my permalink value (which is worked out using
to_param)? I have to create a whole method using regex that returns
something that is exactly the same?
Why am I starting to feel I’m talking to the wall?
You have URLs, .e.g.
/tutorials/1
/tutorials/3
/tutorials/12
You need a method to extract the unique ID from each of those and
return the permalink value. You don’t have to use a regex, it’s just
a common approach. Write it any way you want. But that is the first
step to solving your problem. Unless you just manually create every
rewrite rule, of course.
I would GREATLY appreciate it if you could just give a reply like “If
I had a blog with the same kind of setup, what I could do is write a
redirect like this, as you can get the permalink value by doing this.”
That would be an awesome trick, considering that I don’t have any
idea where your permalink values are coming from. You could be
storing them in the DB, generating them on the fly, scooping them out
of Schrödinger’s cat’s litter box – who knows?
Wait – you know, so you can write that code.
Though as Marnen previously suggested, many of us are available
for contract work
I’m using the to_param method in the model file(s).
ill try to look up some regex as it could improve my general
programming as well as helping with this project.
Although I will eventually prrobably figure this out (or at least I
hope I will), I will still leave it open that if anyone would like to
give me an example or give me a push in the right direction, please do
so.
So, I can’t just pass it my permalink value (which is worked out using
to_param)? I have to create a whole method using regex that returns
something that is exactly the same?
Please Help,
I would GREATLY appreciate it if you could just give a reply like “If
I had a blog with the same kind of setup, what I could do is write a
redirect like this, as you can get the permalink value by doing this.”
You’re not going to get this list’s populace to write your code for you,
no matter how nicely you ask. If you need someone to write your code,
please support the Rails ecosystem (which has been helping you for free)
and hire a consultant.