Hi, I have used scaffold to create my rails project and hence I have a database containing a table called "results" and when i call the "show" action followed by the ID it brings up a list of the relative record and its details. What I want though is for if someone types in say localhost/results/etab-mobile that it maps dynamically to localhost/show/1 but keeps localhost/etab-mobile in the address bar. the "etab-mobile" title is found in the database under "module_name" so can be pulled out for use. I know this can be done in the routes.rb folder statically but would like to do it in the controller so that its not as static. is this possible? thanks, Chris -- 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, I think its possible only thru routes.rb, cannot be done in controller, As i see, if you have "link_name" in your database for each page on site: like: http://site.com/homepage -> redirects to /site/1 http://site.com/about -> /site/3 in table of "menus" its looks id --- link ----------- name --- ... 1 homepage Welcome to Homepage 3 about Everything about us "link" field is used to be a "friendly" link and generated thru routes.rb. i think is simpliest way. look at http://eurobdc.com at their links. Cheerz Chris Gallagher wrote:> Hi, > > I have used scaffold to create my rails project and hence I have a > database containing a table called "results" and when i call the "show" > action followed by the ID it brings up a list of the relative record and > its details. > > What I want though is for if someone types in say > localhost/results/etab-mobile that it maps dynamically to > localhost/show/1 but keeps localhost/etab-mobile in the address bar. the > "etab-mobile" title is found in the database under "module_name" so can > be pulled out for use. > > I know this can be done in the routes.rb folder statically but would > like to do it in the controller so that its not as static. > > is this possible? > > thanks, > > Chris > > -- > 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
that sounds like the way id like to do it but im having trouble getting my head around how to code it: at the moment i have map.connect ''etab-mobile'', :controller => ''results'', :action => ''show'', :id => ''1'' but id like that :id =>''1'' to be loaded in from my database rather than statically as I have other results that id like to show with id =2 and id=3 and so on.... -- 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You cannot display dynamic results under the same route showing in the address bar, except you use POST instead of GET Maybe that would work ... someone would type : http://yoursite.com/results/etab-mobile and the route would be: map.connect ''results/:module_name'', :controller => ''results'', :action => ''show'' then you have params[:module_name] available in your show action and can pull the correct dataset from the DB with find(:first, :conditions => [module_name ?,params[:module_name]]) or sth. similar. greets --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---