Hi, I am a newcomer to the Rails Front. Currently reading chapter 17 of Agile Web Development on Rails. But a burning question, that I would appreciate anyone being able to verify for me! Here goes: What I am hoping of trying to build is a site where I can have a page for individual entry in the database. So if it were users: I wanted to have a page in the the format: www.example.com/user1 AND www.example.com/user2 and display information pertaining to that particular user. How would one go about doing that. Up until now reading in the book, it seems to indicate that I can only have a www.example.com/~controller_here~. Now I also have a faint clue that you can set a controller default(map root). If I was to do that, would I need to have a new controller for each user? That''s the issue because it does not seem much of a DRY way of getting this done. Another quick add-on question that just came to my head while thinking about this, if I was to implement search functionality. Say www.example.com/search/"whateverquery". Is it still possible in that case to like redirect to the result ..if it was "user1" (www.example.com/user1). __ I appreciate you taking the time to read through this question. Rest assured, I''m going at full speed to get the answer to these questions myself. Nothing else keeps me up at 3:53Am :) Thank You, -- Posted via http://www.ruby-forum.com/.
Hi>I can have a page > for individual entry in the database.Did not understand that I think you better to start with an example ./script/generate scaffold User name:string Then watch what happens in config/routes.rb app/models app/views app/controllers> Now I also have a faint clue that you can set a controller default(map > root). If I was to do that, would I need to have a new controller for > each user?example map.root :controller => ''user'' Then what happens is your root page will be mapped to user controller''s index action And here you have to delete or rename public/index.html before doing this Sijo -- Posted via http://www.ruby-forum.com/.
> > Then what happens is your root page will be mapped to user controller''s > index action And here you have to delete or rename public/index.html > before doing this > > > SijoYou sir, are my hero. Thank You so much. -- Posted via http://www.ruby-forum.com/.
Vlad Chvorun wrote: [...]> > You sir, are my hero. > > Thank You so much.Except that I don''t think Sijo''s suggestion will work, if I understand correctly. I think you need something in routes.rb (near the end) like map.connect ''/:username'', :controller => ''users'', :action => ''show_by_name'' But I could be wrong. In any case, this shouldn''t be *too* difficult. You may also need to override User#to_param. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.