MOLTEN wrote in post #965822: > match "/:category/:movie" => redirect("http://netflix.com/search? > category=%{category}&movie=%{movie}") > > The only problems so far are if a category or movie has a space in it, > then I get an error "bad URI(is not URI?):" since it tries to go to > the site with a space still in the URL. How do I substitute spaces > inside symbols with something like a "+"? It has to be before it gets > redirected though. I'd like to be able to just type like netflixit.com/ > dramatic comedy/heroes and it automatically turn the space into a "+" > right before it redirects, instead of manually typing the "+" in > netflixit.com/dramatic+comedy/heroes, which works correctly. So, I > guess before the URL a person types in gets to match > "/:category/:movie", it has to replace spaces with "+".
If you want to do anything useful with this route then you need to create a controller: routes.rb ---------------------- match "/:category/:movie" => "redirector#search" redirector_controller.rb ---------------------- def search # Build your URL url = CGI::escape("netflix.com/search?category=#{params[:category]}&name=#{params[:movie]}&blahtechnical-stuff") # Do anything else you want before redirecting # Redirect to the constructed URL redirect_to(url) end Note: This may be a horrible implementation and may not be suitable for production. Just here to illustrate what sorts of things you can do once you get into an actual controller rather than trying to rely solely on the routes file. P.S. As aluded to earlier Rails may not be the best framework for what you're trying to do unless there's much more that the application will need to do. A Sinatra or simple Rack application may be all you need and would be considerably more efficient for this purpose. -- Posted via http://www.ruby-forum.com/. -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.