James Collier wrote:> Greetings all,
>
> I have a side panel in my app that needs to have a link to the most
> recent 4
> or 5 items in a table. How do I create this link?
>
> For example, I have a controller named widgets, and I want to create a
> link
> to :controller => "widgets", :action => "show",
and then the most recent
> id.
> I want the text link to be the name of the widget.
>
>
>
> Any ideas? Obviously, I''m another newbie..
>
>
>
> James
I have a side panel that shows the most recently viewed items (across
multiple controllers). For example, a user may have viewed a lead, an
order, etc... I want to show the most recent 10 items viewed. Here is
a sample of the shared view file used for the panel:
<% for viewitem in @view_items%>
<tr valign="top" class="ListRow1">
<td width="25px" height="25px"
align="right"><img alt="<%=
viewitem.controller.pluralize %>" src="/images/<%=
viewitem.controller.pluralize %>.gif"></td>
<td style="padding:0px 3px 0px 3px;">
<%= link_to viewitem.value , :controller =>
viewitem.controller, :action => viewitem.action, :id => viewitem.item_id
%>
</td>
<td WIDTH="1" HEIGHT="20"
class="blackLine" NOWRAP><img
src="/images/blank.gif"></td>
</tr>
<% end %>
My "view_items" are whatever your table is where the records are
stored.
I store the name of the controller and the action in this table, but you
should be able to adjust accordingly. If this isn''t what you need then
please let me know and I''ll try to give a more specific example.
Regards,
Michael
--
Posted via http://www.ruby-forum.com/.