I want to disable my navigation depending on two conditions: 1) the page is not the current one, 2) the page is not in the session. I have tried: <%= link_to_unless @page.nil? or current_page?, "My ICA Pages" , :controller => ''page'', :action => ''list''%> --gives me errors <%= link_to_unless( @page.nil?,"",{})do link_to_unless_current "My ICA Pages" , :controller => ''page'', :action => ''list''%> --no link is ever displayed any suggestions. Code examples are always helpful. Thanks in advance, K --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> I want to disable my navigation depending on two conditions: 1) the > page is not the current one, 2) the page is not in the session. > > I have tried: > <%= link_to_unless @page.nil? or current_page?, "My ICA > Pages" , :controller => ''page'', :action => ''list''%> > --gives me errors > <%= link_to_unless( @page.nil?,"",{})do link_to_unless_current "My ICA > Pages" , :controller => ''page'', :action => ''list''%> > --no link is ever displayed > > any suggestions. Code examples are always helpful.Haven''t tried it, but maybe... link_to_unless (@page.nil? || current_page?(params)), "blah blah blah".... -philip --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Consider using @page.blank? instead of @page.nil?. Also, consider inserting this above the statement: <% RAILS_DEFAULT_LOGGER.debug("page was: #{@page} and current_page? is #{current_page?}) %> <% RAILS_DEFAULT_LOGGER.debug("My or expression evaluates to: #{@page.nil? or current_page?}) %> <% RAILS_DEFAULT_LOGGER.debug("My || expression evaluates to: #{@page.nil? || current_page?}) %> If you tail your development.log, it should give you an idea what''s going on. Kim Griggs wrote:> > > I want to disable my navigation depending on two conditions: 1) the > page is not the current one, 2) the page is not in the session. > > I have tried: > <%= link_to_unless @page.nil? or current_page?, "My ICA > Pages" , :controller => ''page'', :action => ''list''%> > --gives me errors > <%= link_to_unless( @page.nil?,"",{})do link_to_unless_current "My ICA > Pages" , :controller => ''page'', :action => ''list''%> > --no link is ever displayed > > any suggestions. Code examples are always helpful. > > Thanks in advance, K > > > > > >-- View this message in context: http://www.nabble.com/disable-link-on-two-conditions-tf3397451.html#a9460550 Sent from the RubyOnRails Users mailing list archive at Nabble.com. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sorry, should have explained myself better. @page is a session variable so @page.nil? is correct. I want to check if the session contains the page (which is a model in my app) I am well aware on how to debug, thanks anyways. The problem is that the things I have tried are not formatted correctly, thats what I am looking for. How do I use two conditions in the link_to_unless or if I can''t, how can I use the block statement in link_to_unless to then call link_to_unless_current, or any other suggestions on how to disable a link depending on two conditions. Thanks, Kim On Mar 13, 11:32 am, "s.ross" <cwdi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Consider using @page.blank? instead of @page.nil?. Also, consider inserting > this above the statement: > > <% RAILS_DEFAULT_LOGGER.debug("page was: #{@page} and current_page? is > #{current_page?}) %> > <% RAILS_DEFAULT_LOGGER.debug("My or expression evaluates to: #...@page.nil? > or current_page?}) %> > <% RAILS_DEFAULT_LOGGER.debug("My || expression evaluates to: #...@page.nil? > || current_page?}) %> > > If you tail your development.log, it should give you an idea what''s going > on. > > > > Kim Griggs wrote: > > > I want to disable my navigation depending on two conditions: 1) the > > page is not the current one, 2) the page is not in the session. > > > I have tried: > > <%= link_to_unless @page.nil? or current_page?, "My ICA > > Pages" , :controller => ''page'', :action => ''list''%> > > --gives me errors > > <%= link_to_unless( @page.nil?,"",{})do link_to_unless_current "My ICA > > Pages" , :controller => ''page'', :action => ''list''%> > > --no link is ever displayed > > > any suggestions. Code examples are always helpful. > > > Thanks in advance, K > > -- > View this message in context:http://www.nabble.com/disable-link-on-two-conditions-tf3397451.html#a... > Sent from the RubyOnRails Users mailing list archive at Nabble.com.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 13, 2007, at 2:43 PM, Kim wrote:> On Mar 13, 11:32 am, "s.ross" <cwdi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Kim Griggs wrote: >> >>> I want to disable my navigation depending on two conditions: 1) the >>> page is not the current one, 2) the page is not in the session. >> >>> I have tried: >>> <%= link_to_unless @page.nil? or current_page?, "My ICA >>> Pages" , :controller => ''page'', :action => ''list''%> >>> --gives me errors >>> <%= link_to_unless( @page.nil?,"",{})do link_to_unless_current >>> "My ICA >>> Pages" , :controller => ''page'', :action => ''list''%> >>> --no link is ever displayed >> >>> any suggestions. Code examples are always helpful. >> >>> Thanks in advance, K >> Consider using @page.blank? instead of @page.nil?. Also, consider >> inserting >> this above the statement: >> >> <% RAILS_DEFAULT_LOGGER.debug("page was: #{@page} and >> current_page? is >> #{current_page?}) %> >> <% RAILS_DEFAULT_LOGGER.debug("My or expression evaluates to: >> #...@page.nil? >> or current_page?}) %> >> <% RAILS_DEFAULT_LOGGER.debug("My || expression evaluates to: >> #...@page.nil? >> || current_page?}) %> >> >> If you tail your development.log, it should give you an idea >> what''s going >> on. >> > Sorry, should have explained myself better. > > @page is a session variable so @page.nil? is correct. I want to check > if the session contains the page (which is a model in my app) > > I am well aware on how to debug, thanks anyways. > > The problem is that the things I have tried are not formatted > correctly, thats what I am looking for. > > How do I use two conditions in the link_to_unless or if I can''t, how > can I use the block statement in link_to_unless to then call > link_to_unless_current, or any other suggestions on how to disable a > link depending on two conditions. > > Thanks, > KimYour problem is initially using ''or'' which is very low precedence: <%= (link_to_unless @page.nil?) or (current_page?, "My ICA Pages" , :controller => ''page'', :action => ''list'') %>> --gives me errorsWith the precedence made explicit, the reason for errors should become obvious. <%= link_to_unless( @page.nil?,"",{}) do link_to_unless_current "My ICA Pages" , :controller => ''page'', :action => ''list''%>> --no link is ever displayedDo you have a test? I suspect that you don''t, but I''ll leave that as an exercise. <%= link_to_unless(@page.nil? || current_page?(:controller => ''page'', :action => ''list''), "My ICA Pages", :controller => ''page'', :action => ''list'') %> Which will be a link having anchor text "My ICA Pages" or just the plain text if either condition is true. If you want different text for the non-link case: <%= link_to_unless(@page.nil? || current_page?(:controller => ''page'', :action => ''list''), "My ICA Pages", :controller => ''page'', :action => ''list'') {|txt| "No link to #{txt}"} %> If you want *nothing at all*, then use: <% unless @page.nil? || current_page?(:controller => ''page'', :action => ''list'') %> <%= link_to("My ICA Pages", :controller => ''page'', :action => ''list'') %> <% end %> Does that get you where you''re trying to go? -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks, yes it does get me were I was trying to go. On 3/13/07, Rob Biedenharn <Rob-GBZH0y1GwQfnZcttdmLDtcI/UQi/AW5J@public.gmane.org> wrote:> > > On Mar 13, 2007, at 2:43 PM, Kim wrote: > > On Mar 13, 11:32 am, "s.ross" <cwdi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Kim Griggs wrote: > >> > >>> I want to disable my navigation depending on two conditions: 1) the > >>> page is not the current one, 2) the page is not in the session. > >> > >>> I have tried: > >>> <%= link_to_unless @page.nil? or current_page?, "My ICA > >>> Pages" , :controller => ''page'', :action => ''list''%> > >>> --gives me errors > >>> <%= link_to_unless( @page.nil?,"",{})do link_to_unless_current > >>> "My ICA > >>> Pages" , :controller => ''page'', :action => ''list''%> > >>> --no link is ever displayed > >> > >>> any suggestions. Code examples are always helpful. > >> > >>> Thanks in advance, K > >> Consider using @page.blank? instead of @page.nil?. Also, consider > >> inserting > >> this above the statement: > >> > >> <% RAILS_DEFAULT_LOGGER.debug("page was: #{@page} and > >> current_page? is > >> #{current_page?}) %> > >> <% RAILS_DEFAULT_LOGGER.debug("My or expression evaluates to: > >> #...@page.nil? > >> or current_page?}) %> > >> <% RAILS_DEFAULT_LOGGER.debug("My || expression evaluates to: > >> #...@page.nil? > >> || current_page?}) %> > >> > >> If you tail your development.log, it should give you an idea > >> what''s going > >> on. > >> > > Sorry, should have explained myself better. > > > > @page is a session variable so @page.nil? is correct. I want to check > > if the session contains the page (which is a model in my app) > > > > I am well aware on how to debug, thanks anyways. > > > > The problem is that the things I have tried are not formatted > > correctly, thats what I am looking for. > > > > How do I use two conditions in the link_to_unless or if I can''t, how > > can I use the block statement in link_to_unless to then call > > link_to_unless_current, or any other suggestions on how to disable a > > link depending on two conditions. > > > > Thanks, > > Kim > > Your problem is initially using ''or'' which is very low precedence: > <%= (link_to_unless @page.nil?) or (current_page?, "My ICA > Pages" , :controller => ''page'', :action => ''list'') %> > > --gives me errors > With the precedence made explicit, the reason for errors should > become obvious. > > > <%= link_to_unless( @page.nil?,"",{}) do link_to_unless_current "My > ICA Pages" , :controller => ''page'', :action => ''list''%> > > --no link is ever displayed > > Do you have a test? I suspect that you don''t, but I''ll leave that as > an exercise. > > <%= link_to_unless(@page.nil? || current_page?(:controller => > ''page'', :action => ''list''), > "My ICA Pages", :controller => ''page'', :action => > ''list'') %> > > Which will be a link having anchor text "My ICA Pages" or just the > plain text if either condition is true. If you want different text > for the non-link case: > > <%= link_to_unless(@page.nil? || current_page?(:controller => > ''page'', :action => ''list''), > "My ICA Pages", :controller => ''page'', :action => > ''list'') {|txt| "No link to #{txt}"} %> > > If you want *nothing at all*, then use: > > <% unless @page.nil? || current_page?(:controller => ''page'', :action > => ''list'') %> > <%= link_to("My ICA Pages", :controller => ''page'', :action => > ''list'') %> > <% end %> > > Does that get you where you''re trying to go? > > -Rob > > Rob Biedenharn http://agileconsultingllc.com > Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org > > > > > >-- Kim Griggs kim.griggs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org "We are all stakeholders in the Karma economy." --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---