Created
May 2, 2012 00:06
-
-
Save libryder/2572537 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def padded_store_link direction | |
| user_store_ids = current_user.store_ids_for_client(@client) | |
| client_store_ids = @client.stores.map(&:id) | |
| sorted_user_store_ids = client_store_ids.select { |i| user_store_ids.include?(i) } | |
| index = sorted_user_store_ids.index(@store.id) | |
| puts "INDEX #{index}" | |
| if direction == "next" | |
| id = sorted_user_store_ids[index+1] | |
| else | |
| id = sorted_user_store_ids[index-1] | |
| end | |
| link_to "#{direction.capitalize} Store", {:action => 'edit_store',:id => id}, {:class => :admin} | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment