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
Post a Comment