Re-post: Problem with dashes in URL / Routes


#1

Hey Guys!

First, I am a complete noob at rails. This is my first attempt at a
website using ruby. I’ve done quite a bit of searching and can’t seem
to find the answer to this question. I’m sure its something completely
obvious I’m missing, lol.

I’m having a little issue getting “link_to” to generate URL’s with “-”
instead of “+”. Some of my URL’s may have a variable on the end that
could have spaces ( ie. domain.com/controller/action/some+variable/ ).
I would like to replace that “+” with a “-” and then remove the dash
before I query the database with that variable. Is it possible to have
the routes do this automatically? Would I use a regex with
:requirements?

Thanks in Advance,
Nick


#2

I would do it in the controller. Get the variable in your controller and
do some+variable.gsub(" ", “-”) and then do the query.

Kind regards,

Nick

http://railshostinginfo.com
Review Rails hosting companies