i've been trying develop controller action user authentication can this:
class postscontroller < applicationcontroller before_filter :authenticate_user! ... and have authentication action redirects previous page after user authenticated. i'm aware there store-and-redirect approaches solve problem. however, doesn't work requires non-get action, i.e. deleting post.
i've found solution rails 2 involves using controller.process method call post action controller. deprecated in rails 3, though. there equivalent method in rails 3? can't find documentation on old controller.process command begin with.
if has suggestion approach, appreciated well.
i have same problem in rails 3 controller.process being deprecated. below failed attempt use rack::methodoverride in place of controller.process (which working me in rails 2). error ro.call below is:
threaderror in user sessionscontroller#create thread 0xb592b994 tried join itself
def demo
params = {'action' => 'create', 'controller' => 'user_sessions', "commit"=>"submit", "user_session"=>{"username"=>"demo", "password"=>"demo"}} request.env['request_method'] = 'post' # throw out existing params , merge stored ones request.parameters.reject! { true } request.parameters.merge!(params) request.path_parameters.reject! { true } request.path_parameters.merge!('action' => 'create', 'controller' => 'user_sessions') request.post["http_x_http_method_override"] = 'post' ro = rack::methodoverride.new rails.application ro.call request.env if response.redirected_to @performed_redirect = true else @performed_render = true end end
might know how correctly use rack::methodoverride send post request?
Comments
Post a Comment