Rendering subnav for GET and POST to the same page

Skip to first unread message

Sep 16, 2013, 2:18:44 PM9/16/13
I have a page that needs to load the same subnav if the page is loaded with either GET or POST. I know that I can use the :method option to specify which one to look for, but I can't seem to get it to respond to both GET and POST. The closes I've gotten to was 

    primary.item :account, 'Account', accounts_path, :method => [:get, :post] do |account|

which then uses POST to load that page when the Account nav item is clicked. How can I achieve this?

Andi Schacke

Sep 16, 2013, 2:52:57 PM9/16/13

the :method param "mimics" the :method param from the rails link_to helper. It can be used to have a "rails style" delete link by passing in :method => :delete. It has nothing to do with how or which subnav element is loaded or displayed. To have control over which subnav is selected, you can either use the :auto_highlight option (which is turned on by default) which makes a subnav active if its parent url matches the current_url. Or you can use :highlights_on with a regexp to specify when a navigation item should be considered active. 

I hope I did not misunderstand your question.


You received this message because you are subscribed to the Google Groups "simple-navigation" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

Sep 16, 2013, 3:54:28 PM9/16/13
Hi Andi - thanks for the quick response. I see that I was wrong about the :method parameter - that makes sense. The issue that I'm having is that the subnav appears when the page is loaded via GET, but not when the page is loaded via POST. Here's a bit more detail about my situation.

I have the following two routes that both load the same page:
  get "accounts" => "accounts#overview"
  post "accounts" => "accounts#overview"

My navigation config is set as so:
    primary.item :account, 'Account', accounts_path do |account|
      account.item :profile, 'Profile', accounts_profile_path
      account.item :letters, 'Letters', accounts_letters_path
      account.item :payment_methods, 'Payment Methods', '/accounts/payment-methods'
      account.item :pending, 'Pending', accounts_pending_path
      account.item :cancel, 'Cancel', accounts_cancel_path, :unless => { @account.blank? || !@account.is_cancelled? }
      account.item :refund, 'Refund', accounts_refund_path, :unless => { @account.blank? || !@account.is_cancelled? }

When I simply click on the "Account" nav item, the subnav loads properly. I also have a search that lists accounts into a table and POSTs to the Account (accounts#overview) page. The reason for this is because I need to store the account id of the selected account in a session variable. Do you have any idea why the subnav would not load when POST is used?

Andi Schacke

Sep 18, 2013, 2:24:59 PM9/18/13
Hi Alec,

is your problem linked to this issue?

Sep 20, 2013, 4:52:33 PM9/20/13
There certainly seem to be some similarities. I'll try implementing some of those workarounds and will follow up. Thanks.
Reply all
Reply to author
0 new messages