Restful_autentication activation


#1

Hi,

I am using the restfull authentication plugin for my website. I am
getting to grips with the rest routes but when a user wnats to activate
their account i am not too sure how to set this up.

In the controller:

users_controller.rb
def activate
self.current_user =
User.find_by_activation_code(params[:activation_code])
if logged_in? && !current_user.activated?
current_user.activate
flash[:notice] = “Signup complete!”
end
redirect_back_or_default(’/’)
end

routes.rb
map.resources :users, :member => { :activate => :get }

Now what this will give me is the following url: /users/:id;activate/ so
if i had the id of the user this would work /users/1;activate/ but i
dont i have the activation code so something like
/users/1f724a1fe4d5152f3138c;activate/

How can i set this up so in the url i can take the activation code, find
out which user it is and activate them using rest. Is it soemthing to
do with the :format .

Any advice appreciated.

JB


#2

John B. wrote:

Hi,

I am using the restfull authentication plugin for my website. I am
getting to grips with the rest routes but when a user wnats to activate
their account i am not too sure how to set this up.

In the controller:

users_controller.rb
def activate
self.current_user =
User.find_by_activation_code(params[:activation_code])
if logged_in? && !current_user.activated?
current_user.activate
flash[:notice] = “Signup complete!”
end
redirect_back_or_default(’/’)
end

routes.rb
map.resources :users, :member => { :activate => :get }

Now what this will give me is the following url: /users/:id;activate/ so
if i had the id of the user this would work /users/1;activate/ but i
dont i have the activation code so something like
/users/1f724a1fe4d5152f3138c;activate/

How can i set this up so in the url i can take the activation code, find
out which user it is and activate them using rest. Is it soemthing to
do with the :format .

Any advice appreciated.

JB

I know how to do it using named routes, something like the below, i was
wondering if there was a more restfull way of doing this as all i have
is the activation code.

map.activate ‘activate/:activation_code’, :controller => ‘users’,
:action => ‘activate’