开发者

Catch action parameter in route

I'm making use of hookbox which handles a socket for web. My browser sends information with javascript to hookbox and hookbox forwards the information to my ruby application.

The problem is that hookbox sends a parameter called action, so I assume it would look like this. /hookbox/index?action=connect&user=test, when I ask for the parameters, instead of connect I get the action index of course. Is there any way I can rewrite my routes so that it w开发者_StackOverflow中文版ould be forwarded to /hookbox/connect&user=test

Kind Regards


I don't know hookbox, I guess it's hookbox who really should create the correct url. But if you can't, you could handle this yourself. Routes ar really just rubycode, so you just might write some ruby code yourself.

  class HookboxController < ApplicationController
    def index
      action = params['action']
      send("#{action}")
    end

    def connect
      #do stuff
    end
  end

now, if params['action']='connect', the connect method would be called with the params (with user=test etc)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜