fixing disappearing options by suung · Pull Request #91 · codeplant/simple-navigation · GitHub
Skip to content

fixing disappearing options#91

Closed
suung wants to merge 6 commits into
codeplant:masterfrom
devolute:master
Closed

fixing disappearing options#91
suung wants to merge 6 commits into
codeplant:masterfrom
devolute:master

Conversation

@suung

@suung suung commented Mar 12, 2012

Copy link
Copy Markdown

hey andi,

problem was:

  1. instance variable with config
  2. several render calls with different levels
  3. first call changes the config removing options.

this seems to fix it.

…emoves data out of the config stored in an instance variable
@mjtko

mjtko commented Mar 24, 2012

Copy link
Copy Markdown
Contributor

@mjtko

mjtko commented Mar 24, 2012

Copy link
Copy Markdown
Contributor

Hi @suung,

I'm trying to determine under exactly what conditions the problem you mention is occurring.

You mention an 'instance variable with config' - what variable are you referring to here?

Also, you mention 'several render calls' - I guess you mean that you're calling render_navigation multiple times in different places in a template.

I would like to get this fixed up so it doesn't cause the problems you're encountering, but without tests or further explanation I'm nervous that doing what is possibly half the job might be worse!

If you could get back to me with a few more details, that'd be much appreciated.

Cheers,

Mark.

@suung

suung commented Apr 3, 2012

Copy link
Copy Markdown
Author

hey mark,

sorry for the delay.

yeah, i am not sure how to test this, but will work somehow.

i currently ran in the same problem, where someone forgot to use our patch.
that's the setup:

- debugger
= render "edit_navigation"
- debugger

where

 debugger
(rdb:13) p @main_navigation
[{:key=>"main_navigation_assignment", :name=>"My Assignments", :url=>"/assignments", :options=>{:section=>"left", :if=>#<Proc:0x007ffbe86aaec8@/home/suung/workspace/development/tarantula/vendor/plugins/devolute-rails-navigation/lib/devolute/patterns/navigation.rb:209 (lambda)>}}, {:key=>"main_navigation_prospect", :name=>"Dispatching", :url=>"/prospects", :options=>{:section=>"left", :if=>#<Proc:0x007ffbe86f51d0@/home/suung/workspace/development/tarantula/vendor/plugins/devolute-rails-navigation/lib/devolute/patterns/navigation.rb:209 (lambda)>}}, {:key=>"main_navigation_review", :name=>"Final Cut", :url=>"/reviews", :options=>{:section=>"left", :if=>#<Proc:0x007ffbe8717d48@/home/suung/workspace/development/tarantula/vendor/plugins/devolute-rails-navigation/lib/devolute/patterns/navigation.rb:209 (lambda)>}}, {:key=>"main_navigation_user_session", :name=>"Sign Out", :url=>"/users/sign_out", :options=>{:method=>:delete, :section=>"right", :if=>#<Proc:0x007ffbe874d3d0@/home/suung/workspace/development/tarantula/vendor/plugins/devolute-rails-navigation/lib/devolute/patterns/navigation.rb:209 (lambda)>}}, {:key=>"main_navigation_user_session", :name=>"Sign In", :url=>"/users/sign_in", :options=>{:section=>"right", :unless=>#<Proc:0x007ffbe876ff20@/home/suung/workspace/development/tarantula/vendor/plugins/devolute-rails-navigation/lib/devolute/patterns/navigation.rb:209 (lambda)>}}, {:key=>"main_navigation_user", :name=>"⚒", :url=>"/users", :options=>{:section=>"right", :if=>#<Proc:0x007ffbe8791e68@/home/suung/workspace/development/tarantula/vendor/plugins/devolute-rails-navigation/lib/devolute/patterns/navigation.rb:209 (lambda)>}, :items=>[{:key=>"user_navigation_level_2_show", :name=>"Show", :url=>"/users/1", :options=>{}}, {:key=>"user_navigation_level_2_new", :name=>"New", :url=>"/users/new", :options=>{}}, {:key=>"user_navigation_level_2_edit", :name=>"Edit", :url=>"/users/1/edit", :options=>{}}, {:key=>"navigation_level_2_back", :name=>"Back", :url=>"http://localhost:3000/"}]}, {:name=>"☺", :key=>"main_navigation_edit_profile", :url=>"/users/1/edit", :options=>{:section=>"right"}}]
(rdb:13) n
/home/suung/workspace/development/tarantula/app/views/users/_edit.html.haml:3
- if resource.errors.any?
(rdb:13) p @main_navigation
[{:key=>"main_navigation_assignment", :name=>"My Assignments", :url=>"/assignments", :options=>{:section=>"left"}}, {:key=>"main_navigation_prospect", :name=>"Dispatching", :url=>"/prospects", :options=>{:section=>"left"}}, {:key=>"main_navigation_review", :name=>"Final Cut", :url=>"/reviews", :options=>{:section=>"left"}}, {:key=>"main_navigation_user_session", :name=>"Sign Out", :url=>"/users/sign_out", :options=>{:section=>"right"}}, {:key=>"main_navigation_user_session", :name=>"Sign In", :url=>"/users/sign_in", :options=>{:section=>"right"}}, {:key=>"main_navigation_user", :name=>"⚒", :url=>"/users", :options=>{:section=>"right"}, :items=>[{:key=>"user_navigation_level_2_show", :name=>"Show", :url=>"/users/1", :options=>{}}, {:key=>"user_navigation_level_2_new", :name=>"New", :url=>"/users/new", :options=>{}}, {:key=>"user_navigation_level_2_edit", :name=>"Edit", :url=>"/users/1/edit", :options=>{}}, {:key=>"navigation_level_2_back", :name=>"Back", :url=>"http://localhost:3000/"}]}, {:name=>"☺", :key=>"main_navigation_edit_profile", :url=>"/users/1/edit", :options=>{:section=>"right"}}]
(rdb:13) 

what this means is:

normally you would render one navigation once. and another somewhere else.
we do it twice. so we notice, the variable changes

if i can breath again and my code gets stable, then i will certainly come back to you with a test

@mjtko

mjtko commented May 31, 2012

Copy link
Copy Markdown
Contributor

Hi @suung,

Any sign of that test yet? :-)

Cheers,

Mark.

@suung

suung commented May 31, 2012

Copy link
Copy Markdown
Author

hey, i just pushed it on our repo. heading to amsterdam now.

cheers

On Thu, 2012-05-31 at 01:48 -0700, Mark J. Titorenko wrote:

Hi @suung,

Any sign of that test yet? :-)

Cheers,

Mark.


Reply to this email directly or view it on GitHub:
#91 (comment)

@ghost ghost assigned mjtko Jul 16, 2012
@andi

andi commented Aug 18, 2012

Copy link
Copy Markdown
Collaborator

I think I don't understand the problem here. Can you briefly wrap up your setup again and explain exactly what the problem is?

Thanks
Andi

@suung

suung commented Oct 24, 2012

Copy link
Copy Markdown
Author

hey andi, good you are back.

basically in the first render call, stuff gets .delete(:bla) out of the options hash. if, for some reason, you might render the same (dynamic) navigation twice, you loose it. makes sense, if you think about it.

cheers

@simonc

simonc commented Mar 5, 2014

Copy link
Copy Markdown
Contributor

If I understand the problem. Calling render_navigation twice was causing the conditions not to be applied on the second call.

If that's precisely the issue here, it's working correctly with the current implementation.

@suung

suung commented Mar 5, 2014

Copy link
Copy Markdown
Author

most likely it has been fixed. I don't know, there was a

options.delete(...) scenario in a nesting above 1 level.

it is very obvious in the code. if it is fixed, it is not in the code anymore, maybe someone can take care for this.

anyway here is my work including tests. https://github.com/devolute/simple-navigation/commits/master
we switched to an own implementation,

@simonc

simonc commented Mar 5, 2014

Copy link
Copy Markdown
Contributor

@simonc simonc closed this Mar 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants