ruby on rails - redirect_to current_user with params -
how can pass parameters current_user redirect?
# sessionhelper.rb def current_user if(user_id = session[:user_id]) @current_user ||= user.find(user_id) else @current_user = nil end end #somecontroller.rb def some_action redirect_to current_user, param1: "bubbles" end # routes.rb resources :doctors, :admins, :agencies # line handles current_user path
such resulting url foo.com/?param1='bubbles'. confusing thing here is, use sti different types of users, every user type has own 'show' url, approach
redirect_to controller: 'thing', action: 'edit', id: 3, something: 'else'
would not work, since every user type has own controller.
you can use
redirect_to polymorphic_path(current_user, something:'else')
Comments
Post a Comment