开发者

RAILS: One single controller in the "/" site-root taking variable requests

being quite new to the rails framework i dont know exactly where i missed the spot.

i want to do the following:

  1. someone sends a rest request (get,put,post,delete) in the form of /var1/var2/va开发者_如何学编程r3.var4
  2. i want to catch all 4 vars
  3. nothing else will run on this app. i do not need views, etc.
  4. my rails app responds with an appropriate response object

right now i don't get around the routes.rb part. i got this so far:

scope "/" do
   post ":var1/:var2[/:var3[.:var4]]" => "rest_proxy#post"
   get ":var1/:var2[/:var3[.:var4]]" => "rest_proxy#get"
   put ":var1/:var2[/:var3[.:var4]]" => "rest_proxy#put"
   delete ":var1/:var2[/:var3[.:var4]]" => "rest_proxy#delete"
end

my controller rest_proxy exists, the methods exist, but i get a "no route" error, no matter what i do so there must be something fundamentally wrong.

rake route shows the quivalent of what you see above.

if anyone could point me into the right direction that would be awesome (also about the response object, but that shouldn't be a big deal, right...?)...

thanks and regards, anton


Try this in your routes.rb

post ":var1/:var2(/:var3(/:var4))" => "rest_proxy#post"
put ":var1/:var2(/:var3(/:var4))" => "rest_proxy#put "
get ":var1/:var2(/:var3(/:var4))" => "rest_proxy#get"
delete ":var1/:var2(/:var3(/:var4))" => "rest_proxy#delete"
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜