Hi Colin,

Thank you for your quick response:

I got the link I wanted working perfectly, but not the conditional
part, which would be "icing on the cake."  Following are the gory
details.  If you can spot how I can be rescued from my fumbling,  I'd
be most appreciative.

Best wishes,
Richard

The following in app\views\vendors\show.html.erb works perfectly, but
it's displayed unconditionally:
<%= link_to 'New Expense', '/expenses/new' %>
(A verticule separator from preceding links also displays perfectly,
by also is displayed unconditionally.)

The following produced no syntax error, but it did not display the
link (Vendor::@showExpenseNew == true):
<%= @showExpenseNew ? (link_to 'New Expense', '/expense/new') : "" %>

The following produced no syntax error, but did not display the link
(Vendor::@showExpenseNew == true):
<%= link_to 'New Expense', '/expense/new' if @showExpenseNew %>

The following produced no syntax error, but it did not display the
link (Vendor::@showExpenseNew == true):
<% if @showExpenseNew -%>
    <%= link_to 'New Expense', '/expense/new' %>
<% end -%>

The following produced a syntax error (even worse for lower-case
"vendor")
<% if Vendor/@showExpenseNew -%>
    <%= link_to 'New Expense', '/expense/new' %>
<% end -%>

On Apr 14, 11:30 am, Colin Law <[email protected]> wrote:
> On 14 April 2010 16:19, RichardOnRails
>
> <[email protected]> wrote:
> > I've got two entities created by scaffolding: Expense & Vendor
>
> > In Expense#new there's a form with a Vendors-drop-down and a NewVendor-
> > button.
> > The latter button brings up Vendor#new.
> > The Create button in Vendor#new brings up Vendor#show with Edit & Back
> > links.
>
> > I want to append a third link conditionally to Vendor#show: if the
> > Expense#new form led to the Vendor#show display,  I want a
> > "Return:Expense/New" link to accompany the Edit & Back links.
>
> > Is there a "Rails Way" to do this?
>
> You can set a flag in the controller at the point you know that you
> want to show the link
> @show_return_link = true
> Then test this in the view to see whether to show the link or not
> <%= link_to ....  if @show_return_link %>
>
> 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.

Reply via email to