Access params in the view directly. (use render plugin)

16 views
Skip to first unread message

Billy Zheng

unread,
Aug 7, 2021, 11:03:28 AMAug 7
to Roda

I am a little curious, we can't access params in the view.

i guess we have to pass params to the view with locals: {params: params} or @params, right?

Why we are not pass params to view directly?

Thank you.

Jeremy Evans

unread,
Aug 7, 2021, 11:23:17 AMAug 7
to ruby...@googlegroups.com
The view context is the same as the routing tree context. You can do request.params in the view to get access to the params.  With the r plugin, you can use r.params.  If you want to call params directly in the view or the routing tree, you can use:

  plugin :delegate
  request_delegate :params

Thanks,
Jeremy
Reply all
Reply to author
Forward
0 new messages