Hey, I have a social network web app with ruby on rails and users can see their profile like this: /profiles/2-admin Now i want to make an alias or something with the route "/me" so it would show the same as profiles/2-admin so when i go to this: http://localhost:3000/me it shows me the same as http://localhost:3000/profiles/2-admin so the "me" would show the info from the currently logged in user! Ho can i do that? I have tried several things, but nothing succeeded.. Thank you, Wouter
Wouter wrote:> Hey, > > I have a social network web app with ruby on rails and users can see > their profile like this: /profiles/2-admin > Now i want to make an alias or something with the route "/me" so it > would show the same as profiles/2-admin > > so when i go to this: http://localhost:3000/me it shows me the same as > http://localhost:3000/profiles/2-admin > so the "me" would show the info from the currently logged in user! > > Ho can i do that? > > I have tried several things, but nothing succeeded..If you already have an action that lets a user see their profile, then you could do something like this: map.connect ''/me'', :controller => ''profiles'', :action => ''user_profile_action'' Change "user_profile_action" to whatever the action is called. Whoever follows the /me route should be shown the page with their profile on it. If you don''t already have such an action, I think creating one would be the best way. HTH Matt
Hey, Thank you for your answer! When i try this i got this error message Couldn''t find Profile without an ID How to solve this? On Jul 16, 10:27 pm, Matt Harrison <iwasinnamuk...-ja4MoDZtUtVl57MIdRCFDg@public.gmane.org> wrote:> Wouter wrote: > > Hey, > > > I have a social network web app with ruby on rails and users can see > > their profile like this: /profiles/2-admin > > Now i want to make an alias or something with the route "/me" so it > > would show the same as profiles/2-admin > > > so when i go to this:http://localhost:3000/meit shows me the same as > >http://localhost:3000/profiles/2-admin > > so the "me" would show the info from the currently logged in user! > > > Ho can i do that? > > > I have tried several things, but nothing succeeded.. > > If you already have an action that lets a user see their profile, then > you could do something like this: > > map.connect ''/me'', :controller => ''profiles'', :action => > ''user_profile_action'' > > Change "user_profile_action" to whatever the action is called. Whoever > follows the /me route should be shown the page with their profile on it. > > If you don''t already have such an action, I think creating one would be > the best way. > > HTH > > Matt
And why cant i do http://localhost:3000/me.xml (No route matches "/ me.xml") On Jul 16, 10:46 pm, Wouter <wouterg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey, > > Thank you for your answer! > > When i try this i got this error message > > Couldn''t find Profile without an ID > > How to solve this? > > On Jul 16, 10:27 pm, Matt Harrison <iwasinnamuk...-ja4MoDZtUtVl57MIdRCFDg@public.gmane.org> > wrote: > > > Wouter wrote: > > > Hey, > > > > I have a social network web app with ruby on rails and users can see > > > their profile like this: /profiles/2-admin > > > Now i want to make an alias or something with the route "/me" so it > > > would show the same as profiles/2-admin > > > > so when i go to this:http://localhost:3000/meitshows me the same as > > >http://localhost:3000/profiles/2-admin > > > so the "me" would show the info from the currently logged in user! > > > > Ho can i do that? > > > > I have tried several things, but nothing succeeded.. > > > If you already have an action that lets a user see their profile, then > > you could do something like this: > > > map.connect ''/me'', :controller => ''profiles'', :action => > > ''user_profile_action'' > > > Change "user_profile_action" to whatever the action is called. Whoever > > follows the /me route should be shown the page with their profile on it. > > > If you don''t already have such an action, I think creating one would be > > the best way. > > > HTH > > > Matt > >
Ok it works now this is my action def show_me @user = Profile.find(@p) respond_to do |wants| wants.html {redirect_to profile_path(@p)} wants.xml {render :xml => @user.to_xml } end end and this my route map.connect ''/me'', :controller => ''profiles'', :action=> ''show_me'' but when i try to access /me.xml i get No route matches "/me.xml" Me.xml is the same as /profiles/2-admin.xml (xml file from profile). How can i do this? On Jul 16, 10:49 pm, Wouter <wouterg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> And why cant i dohttp://localhost:3000/me.xml(No route matches "/ > me.xml") > > On Jul 16, 10:46 pm, Wouter <wouterg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hey, > > > Thank you for your answer! > > > When i try this i got this error message > > > Couldn''t find Profile without an ID > > > How to solve this? > > > On Jul 16, 10:27 pm, Matt Harrison <iwasinnamuk...-ja4MoDZtUtVl57MIdRCFDg@public.gmane.org> > > wrote: > > > > Wouter wrote: > > > > Hey, > > > > > I have a social network web app with ruby on rails and users can see > > > > their profile like this: /profiles/2-admin > > > > Now i want to make an alias or something with the route "/me" so it > > > > would show the same as profiles/2-admin > > > > > so when i go to this:http://localhost:3000/meitshowsme the same as > > > >http://localhost:3000/profiles/2-admin > > > > so the "me" would show the info from the currently logged in user! > > > > > Ho can i do that? > > > > > I have tried several things, but nothing succeeded.. > > > > If you already have an action that lets a user see their profile, then > > > you could do something like this: > > > > map.connect ''/me'', :controller => ''profiles'', :action => > > > ''user_profile_action'' > > > > Change "user_profile_action" to whatever the action is called. Whoever > > > follows the /me route should be shown the page with their profile on it. > > > > If you don''t already have such an action, I think creating one would be > > > the best way. > > > > HTH > > > > Matt > >
worked for me like in this thread http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/5dc070d84feb9d7f THANX for the help On Jul 16, 10:59 pm, Wouter <wouterg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ok it works now > this is my action > > def show_me > @user = Profile.find(@p) > respond_to do |wants| > wants.html {redirect_to profile_path(@p)} > wants.xml {render :xml => @user.to_xml } > end > end > > and this my route > > map.connect ''/me'', :controller => ''profiles'', :action=> ''show_me'' > but when i try to access /me.xml i get No route matches "/me.xml" > > Me.xml is the same as /profiles/2-admin.xml (xml file from profile). > > How can i do this? > > On Jul 16, 10:49 pm, Wouter <wouterg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > And why cant i dohttp://localhost:3000/me.xml(Noroute matches "/ > > me.xml") > > > On Jul 16, 10:46 pm, Wouter <wouterg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hey, > > > > Thank you for your answer! > > > > When i try this i got this error message > > > > Couldn''t find Profile without an ID > > > > How to solve this? > > > > On Jul 16, 10:27 pm, Matt Harrison <iwasinnamuk...-ja4MoDZtUtVl57MIdRCFDg@public.gmane.org> > > > wrote: > > > > > Wouter wrote: > > > > > Hey, > > > > > > I have a social network web app with ruby on rails and users can see > > > > > their profile like this: /profiles/2-admin > > > > > Now i want to make an alias or something with the route "/me" so it > > > > > would show the same as profiles/2-admin > > > > > > so when i go to this:http://localhost:3000/meitshowsmethe same as > > > > >http://localhost:3000/profiles/2-admin > > > > > so the "me" would show the info from the currently logged in user! > > > > > > Ho can i do that? > > > > > > I have tried several things, but nothing succeeded.. > > > > > If you already have an action that lets a user see their profile, then > > > > you could do something like this: > > > > > map.connect ''/me'', :controller => ''profiles'', :action => > > > > ''user_profile_action'' > > > > > Change "user_profile_action" to whatever the action is called. Whoever > > > > follows the /me route should be shown the page with their profile on it. > > > > > If you don''t already have such an action, I think creating one would be > > > > the best way. > > > > > HTH > > > > > Matt > >