Following up on what Bob Smith posted on 4/21 and Hassan Schroeder on
4/24,
here's what I've got working:
======= app\views\vendors\show.html.erb =====
[snip]
<%= link_to 'Edit', edit_vendor_path(@vendor) %> | <%# From scaffold -
%>
<%= link_to 'Back', vendors_path %> <%# From
scaffold -%>
<%# params['show_new_expense_page'] = true %>
<% if params['show_new_expense_page'] -%>
|
<%= link_to 'New Expense', '/expenses/new' %>
<% end -%>
<% params['show_new_expense_page'] = false %>
============== end ===================
With the "params ... = true" line commented out, I get two links:
Edit | Back
Un-commented, I get three links as desired, and they all work:
Edit | Back | New Expense
My intention is to have the "New Expense" link visible when a
particular link was previously clicked in the following page:
======= app\views\expenses\new.html.erb =====
[snip]
<% @current_vendors =
Vendor.find(:all, :order=>"nickname").collect { |v|
v.nickname + parens(v.qbname) } %>
<%= f.select :vendor, @current_vendors %>
<% params['new_expense_page'] = true -%>
<%= link_to 'New
Vendor', :controller=>'vendors', :action=>'new' %>
[snip]
================= end =================
But the "params ... true" setting is not conveyed to the app\views
\vendors\show.html.erb page.
1. Can this be fixed?
2. If not, will using session rather than params work?
3. Or can I access the "previous page" value in the app\views\vendors
\show.html.erb page and test whether the previous page was app\views
\expenses\new.html.erb?
Again, thanks to all of you for your past responses. I'd be grateful
for any additional ideas you may offer.
--
Richard
On Apr 24, 6:47 pm, Hassan Schroeder <[email protected]>
wrote:
> On Sat, Apr 24, 2010 at 2:53 PM, RichardOnRails
>
> <[email protected]> wrote:
> > I had to work on adding authenticated users to my app, so I had to
> > back-burner the conditional-link issue. I nevertheless would like to
> > keep trying to learn how to do this.
>
> You're making this wildly overly complicated.
>
> Stick this in a view file:
>
> <% @foo = "bar" %>
> <% @state = false %>
> <%= @foo if @state %>
>
> See what appears. Change @state to true and see what appears.
>
> If the variable you're using to eval true/false gives you different and/or
> unexpected results, that variable is not what you think it is.
>
> Use debug or inspect or logging to figure out why.
>
> HTH,
> --
> Hassan Schroeder ------------------------ [email protected]
> twitter: @hassan
>
> --
> 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.