# Newbie... is this possible?

**URL:** <https://www.ruby-forum.com/t/newbie-is-this-possible/103499>\
**Category:** Rails\
**Created:** [May 7, 2007, 6:43am UTC](https://www.ruby-forum.com/t/newbie-is-this-possible/103499 "2007-05-07T06:43:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![blunte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b782af/32.png) [@blunte](https://www.ruby-forum.com/u/blunte)\
**Post date:** [May 7, 2007, 6:43am UTC](https://www.ruby-forum.com/t/newbie-is-this-possible/103499/1 "2007-05-07T06:43:44Z")

</div>

Howdy.

I’m new at Rails, but I think I understand the concept. Now I’m  
trying to map that to what I’ve done in the past with JSP/Java/Tomcat,  
and I have a specific problem I need to solve.

A client likes to have his registered users have their own portal  
pages, like “[thesite.com](http://thesite.com/someuser)”. In JSP I just added logic to the  
404 handling such that if the path name “someuser” was a registered  
user in the database, then it would generate a page appropriate for  
them. Then, since this was a referral-based system (in terms of  
membership-benefits), if the visitor signed up on someuser’s page,  
someuser would get credit for it.

How, in Rails, might such a thing be done? Would it be a hack like  
what I did on Tomcat in JSP, with 404 handling? Or is there some  
other facility for _faking_ pages that don’t exist?

An example or other explanation of similar systems would be wonderful.

Thanks!

---

<div class="post-metadata">

**Author:** ![blunte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b782af/32.png) [@blunte](https://www.ruby-forum.com/u/blunte)\
**Post date:** [May 7, 2007, 7:09am UTC](https://www.ruby-forum.com/t/newbie-is-this-possible/103499/2 "2007-05-07T07:09:45Z")

</div>

blunte wrote:

> A client likes to have his registered users have their own portal

I think you’d basically do it the same way. Map an action as the  
last-resort action and in there try to look up a user for the path. If  
you don’t find a user /then/ you do the 404.

Read up on routes.rb… in fact, the comments in the generated routes.rb  
might be enough.

b

---

<div class="post-metadata">

**Author:** ![blunte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b782af/32.png) [@blunte](https://www.ruby-forum.com/u/blunte)\
**Post date:** [May 7, 2007, 7:15am UTC](https://www.ruby-forum.com/t/newbie-is-this-possible/103499/3 "2007-05-07T07:15:45Z")

</div>

On 5/7/07, Ben M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> might be enough.
> 
> b

Yes have a look at doing this with routes.

I hesitate to provide an actual route, but if you look at the general  
route

map.connect ‘/:controller/:action/:id’

This shows how you can construct a paraeterized url.

map.connect ‘/users/:username’, :controller =\> ‘users’, :action =\>  
‘blah’

would provide the action in users → blah with the param[:username]

There is great docs on the rubysite for making really complex routes.

HTH  
Cheers

---

<div class="post-metadata">

**Author:** ![blunte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b782af/32.png) [@blunte](https://www.ruby-forum.com/u/blunte)\
**Post date:** [May 7, 2007, 7:22am UTC](https://www.ruby-forum.com/t/newbie-is-this-possible/103499/4 "2007-05-07T07:22:45Z")

</div>

In routes:  
map.connect “:id”, :controller =\> “users”, :action =\> “show”

put this last. So all your other controllers take precedent

Zach I.  
â†’ Blog â€” [http://www.zachinglis.com](http://www.zachinglis.com)  
â†’ Company â€” [http://www.lt3media.com](http://www.lt3media.com)  
â†’ Portfolio â€” [http://portfolio.zachinglis.com](http://portfolio.zachinglis.com)

---

<div class="post-metadata">

**Author:** ![blunte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b782af/32.png) [@blunte](https://www.ruby-forum.com/u/blunte)\
**Post date:** [May 7, 2007, 11:30pm UTC](https://www.ruby-forum.com/t/newbie-is-this-possible/103499/5 "2007-05-07T23:30:12Z")

</div>

Thanks for the good responses!

I’ll look into “routes”.
