ruby - Sinatra/Rack params[] in before block -


i'm making site using sinatra, going well, or until needed access params[] hash in before block.

basically, i'm trying this:

before   if params[:forum_id]     @forum = forum.find(params[:forum_id])     build_breadcrumbs(@forum.parents)     # ... more code, snipped keep short   end end 

but thing is, can't call params[] hash in before block, have ideas?

the reason i'm putting code in before block because i'd rather not have go , put in every 1 of get , post blocks every page.

from docs:

before filters evaluated before each request within same context routes , can modify request , response.

since happens before actual request, can't access request parameters. can put repetitive code method , call in route blocks.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -