I have an activation link. I want the user to click on the link, kinda like this... domain.com/users/45/activate/1jf872 The number after "users" would be the user id, and the string after "activate" would be the activation code. In the link above it would be user id 45 and activation code 1jf872. I have no problem sending the email. My problem is getting the route (the url) recognized. I have this in routes... ---------------------------------- resources :users do member do get :activate end end ---------------------------------- users_controller.rb ---------------------------------- def activate @user = User.find(params[:id]) end ----------------------------------- Which finds the user. But how can I make the query to find by both the user id and the activation code? like select users where users.id = 45 and activation_code = 1jf872 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''m trying to get a url like /users/45/invitation/ej3j3j (for invitation form, where you enter the password) and another /users/45/activate (for submitting the form) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 1 August 2011 20:35, Leonel *.* <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I''m trying to get a url like > > /users/45/invitation/ej3j3j (for invitation form, where you enter the > password)You could use /users/45/invitation?activation=ej3j3j or something similar. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
routes.rb ----------------------- resources :users do member do get :invitation post :activate end end ------------------------ 1) I go to users/78/invitation (where the form is) 2) I submit the form and goes to this url users/78/activate 3) but gives me this error "No route matches "/users/78/activate" Whyyyyyy? rake routes --------------------------- invitation_user GET /users/:id/invitation(.:format) {:action=>"invitation", :controller=>"users"} activate_user POST /users/:id/activate(.:format) {:action=>"activate", :controller=>"users"} -------------------------------------------------- -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Aug 1, 2011, at 2:44 PM, Leonel *.* wrote:> I have an activation link. I want the user to click on the link, kinda > like this... > > domain.com/users/45/activate/1jf872 > > The number after "users" would be the user id, and the string after > "activate" would be the activation code. In the link above it would be > user id 45 and activation code 1jf872. > > I have no problem sending the email. My problem is getting the route > (the url) recognized. > > I have this in routes... > ---------------------------------- > resources :users do > member do > get :activate > end > endtry get '':activate/:activation_code''> ---------------------------------- > users_controller.rb > ---------------------------------- > def activate > @user = User.find(params[:id]) > end > -----------------------------------Along those same lines, try User.find_by_id_and_activation_code(params)> > Which finds the user. But how can I make the query to find by both the > user id and the activation code? > > like select users where users.id = 45 and activation_code = 1jf872Walter> > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Davis wrote in post #1014258:> try get '':activate/:activation_code'' > > Along those same lines, try User.find_by_id_and_activation_code(params)Thanks, but I tried it and I get this error when trying to start the server... Exiting /var/lib/gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/routing/mapper.rb:171:in `default_controller_and_action'': missing :action (ArgumentError) from /var/lib/gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/routing/mapper.rb:72:in `normalize_options!'' -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Aug 1, 2011, at 4:11 PM, Leonel *.* wrote:> Walter Davis wrote in post #1014258: >> try get '':activate/:activation_code'' >> >> Along those same lines, try >> User.find_by_id_and_activation_code(params) > > Thanks, but I tried it and I get this error when trying to start the > server... > > Exiting > /var/lib/gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/routing/ > mapper.rb:171:in > `default_controller_and_action'': missing :action (ArgumentError) > from > /var/lib/gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/routing/ > mapper.rb:72:in > `normalize_options!'' >Try ''activate/:activation_code'' instead -- There wouldn''t be any map to :activate (the symbol) since it doesn''t exist in your application. Have a read through the routing guide, too, I may have something wrong. Try using a match statement rather than get directly. I''m not sure if this syntax is supported by get. Walter> -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.