Hi Sven,
I would probably not have that code in the view
<%= lastlogin = computer.useractions.first(:conditions => {:actiontype
=> "login"}) h lastlogin.macuser.display_name if lastlogin %>
I might hide the logic in computer model so
<%= h computer.last_login if computer.has_last_login? %>
Or at least setup @last_login variable in controller (assuming this is
a singular view of the computer resource) to avoid having those logic
in the view.
My preference would be to put it in model, at least you'll be able to
unit test them.
Cheers,
Andy
2009/8/6 Sven Schott <[email protected]>:
> Hi guys
> Just a quickie. I have a rails app with some basic relations (user <=
> useraction => computer) and I'm referencing a user from a computer view
> through a useraction. I had an issue with computers not having a useraction
> and was wondering if this was considered bad form (in the view):
> <%= lastlogin = computer.useractions.first(:conditions => {:actiontype =>
> "login"})
> h lastlogin.macuser.display_name if lastlogin %>
> Sven
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
or Rails Oceania" 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/rails-oceania?hl=en
-~----------~----~----~----~------~----~------~--~---