hello,
Im trying to create a helper method for my admin links. in quite a few views i have the code
<% if current_user %>
<%= link_to "Edit", edit_model_path(model) %>
<%= link_to "New", new_model_path %>
<%= link_to "Delete", model, :confirm => "Your a Noob", :method
=> :delete %>
<% end %>
that only display these when logged in.
I would like to do something like this in their place
<%= admin_links(model) %>
and pass the current item into the application helper method
def admin_links(m)
if current_user
a = "#{link_to "edit" edit_m_path(m)}"
a << "#{link_to "new" new_m_path}"
a << "#{link_to "Delete", m, :confirm => "Your a Noob", :method
=> :delete}"
end
end
Or something of the like. Im not as skilled in the way of helpers but would like to be.
any help would be great.
Thanks in advance
Bob