Hi Jason,
I''ll give this a shot:
Let''s say you store the active button name in a variable called
@active_button_name.
In your view, you could just add this into the href link:
<%= ''id = "active"'' if nav_button.name ==
@active_button_name %>
So, this would change your view code to:
<% @nav_buttons.each do |nav_button| %>
<li><a href="#" class="nav" <%= ''id =
"active"'' if nav_button.name
== @active_button_name %>><%=h nav_button.name
%></a></li>
<% end %>
Tom
On 12/7/05, Jason Pfeifer <jpfeifer-fVOoFLC7IWo@public.gmane.org>
wrote:> Greetings,
>
> I appreciate the help from here as I seem to be asking the noob
> questions a lot, but what is a good way to deal with navigation pulled
> from a database?
>
> I have this in my view:
>
> <% @nav_buttons.each do |nav_button| %>
> <li><a href="#" class="nav"><%=h
nav_button.name %></a></li>
> <% end %>
>
> this in my controller
>
> def index
> shownav
> end
> def shownav
> @nav_buttons = NavButton.find(:all)
> end
>
> and I want to make it so that one of the class="nav" list items
has an
> id="active" decided by a default variable for the homepage, which
I will
> assign a value to as another section is clicked. I realize this is
> probably pretty micky mouse for most on this list, but I promise once I
> am up to speed on rails a bit more I''ll help the new guys around
here :-)
>
> Cheers,
>
> Jason
>
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>