current_page?


Sometimes we come to scenario, we need to find out what the current page is. The best I could do was this:

1. current_page?(options)

Will return true if the current request URI was generated by the given options.
Let’s say we’re in the /shop/checkout?order=desc action.
current_page?(:action => ‘process’)
# => false

current_page?(:controller => ‘shop’, :action => ‘checkout’)
# => true

2. request.path_parameters

this should return a hash along the controller and action.
{:action => ‘my_action’, :controller => ‘my_controller’}

Thanks

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s