Ruby on Rails Wednesday, June 30, 2010

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."

Thanks In Advance,

Joe

On 30 June, 02:26, Hassan Schroeder <hassan.schroe...@gmail.com>
wrote:
> On Tue, Jun 29, 2010 at 1:37 PM, Joe <j...@dev-hq.co.uk> wrote:
> > 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...
>
> But one last try. Your original example:
>
> http://127.0.0.1:3000/categories/1-css/tutorials/12-test9http://127.0.0.1:3000/tutorials/12-test9http://127.0.0.1:3000/categories/1/tutorials/12http://127.0.0.1:3000/tutorials/12
>
> 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.
>
> --
> Hassan Schroeder ------------------------ hassan.schroe...@gmail.com
> twitter: @hassan

--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment