> Something is still not working as you think it is. You're right about that, especially the practice of setting @xxx in one controller and (correctly) referencing it's value in second (unrelated by hierarchy) controller. I think that can only work by meta-programming magic. I'm going to post a question about that at some future time when I'm not consumed by the need for a deliverable.
> ... there should be no need to reset it for another action. I left the conclusion out of my description of the problem, which stated in full is: Failure to employ this reset leads to, e.g. clicking "New Expense" in app\views\expenses\new.html.erb, clicking "Vendor" in app\views\expenses\new.html.erb clicking "Show" on any of the vendors displayed in app\views\vendors \index.html.erb. leads to three links, "Edit | Back | New Expense" where there should only be two: "Edit | Back" Adding the reset clause led to correct behavior in a couple of tests, I believe. In light of your misgivngs, I thought I should remove all the params I introduced earlier. Now, the extra link appears again at times I deem to be inappropriate. So either I was wrong before or introduced another error. In any case, I can't spend any more time on this. As I just posted Hassan, I'll get back to this issue after I finish adding authenticated users and package a "ver. 1" deliverable. > I have just seen your next post in reply to Marnen's suggestion on > testing. I suggest you run for cover. I'm a mere needle in a haystack comprised hundreds of millions of Americans. Finding me to inflict punishment for violating "good practices" will be inordinately difficult :-) Thanks again for you continued contribution to my Rails education. I hope you don't find me incorrigible nor ineducable. Best wishes, Richard On Apr 26, 8:51 am, Colin Law <[email protected]> wrote: > On 26 April 2010 13:31, RichardOnRails > > > > <[email protected]> wrote: > > Hi Colin, > > >> In the _controller_ method that is rendering the page that has the > >> conditional link displayed set a variable > >> @show_new_expense_page = true > >> at the point in the code where you know that you wish to show the link. > >> In the view then just use if @show_new_expense_page on the link display. > > =============== > > Colin > > You're right. I didn't [fully] understand your advice. > > Specifically, I didn't take note of: > > "at the point in the code where you know that you wish to show the > > link". > > > Now that I do, the short answer is IT WORKS!! But why, when I need > > to set a variable in one controller and access a variable of the same > > name in a DIFFERENT controller? Following your advice, > > > I wrote: > > 1. Set @show_new_expense_page = true in > > app\controllers\expenses_controller.rb#new > > > 2. Reference @show_new_expense_page in > > app\controllers\vendors_controller.rb#show > > > This approach works: > > when I click "New Expense" link in app\views\expenses\new.html.erb and > > then click Create in app\views\expenses\new.html.erb, > > I then see the following links displayed: > > Edit | Back | New Expense > > > But, there's a glitch: I need to reset �...@show_new_expense_page to > > false > > after exiting app\views\expenses\new.html.erb by any of the six links > > in it: > > Home Vendor Expense Edit | Back | New Expense > > > Failure to employ this reset leads to, e.g. > > clicking "New Expense" in app\views\expenses\new.html.erb, > > clicking "Vendor" in app\views\expenses\new.html.erb > > clicking "Show" on any of the vendors displayed in app\views\vendors > > \index.html.erb. > > > But the following ameliorates this problem:: > > === app\controllers\vendors_controller.rb === > > class VendorsController < ApplicationController > > [snip] > > def index > > �...@vendors = Vendor.all > > �...@show_new_expense_page = false > > [snip] > > > Maybe another navigation will, over time, reveal another weakness. > > But armed with this new understanding, acquired from you, will see me > > over any such hurdles. > > Something is still not working as you think it is. An @ variable set > in a controller action only has life into the rendered view from that > action, there should be no need to reset it for another action. I > suggest you use ruby-debug (look at the rails guide on debugging, > google rails guides if necessary) and break into you actions and views > and work out what is going on. Also study the log file to see exactly > what is happening. > > I have just seen your next post in reply to Marnen's suggestion on > testing. I suggest you run for cover. > > Colin > > -- > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group > athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

