Search This Blog

Tuesday, September 4, 2012

ROR strong and steady


My experience:
Today opened my project again and decided to do a bit of refactoring. The command
rake routes
was very helpful. I saw the route name there and modified my redirect to statements. Code became more readable and clear.
Then came the devise problem. Controller of devise was nowhere to be seen ! After sign out i wanted users to be redirected to home page. But how do i do it without the controllers of devise. (for those who don't know devise,.. its a gem which helps in implementing authentication in your application) After a bit of googling i found that everything i needed to know about devise is in wiki page of devise in github itself!
by implementing the following private method in application_controller i was able to control the redirection.


  def after_sign_out_path_for(users)
    home_path
  end


in routes i have written this,
 get "/home/index", :to=>"home#index", :as=>"home" 
so everything works nicely as expected !
after the user signs out , action: index of controller: home is called.




No comments:

Post a Comment