What you're trying to do is called "denormalization" and you generally 
want to avoid it unless you have a good reason.

You can remove the name field and add something like this:

def name
   user.try.name
end

Bryan


hobo_hippy wrote:
> I've got this timesheet class with a name field and it belongs to a
> user. How can I make the name field automatically use the user name?
> Since it belongs to a user, and whoever created it is the user, how do
> I make that user's name show in the name :string field? Is this
> something you'd use a helper for? Never seen any examples of one of
> those so if that's the case, I'd appreciate an example.
> 
> class Timesheet < ActiveRecord::Base
> 
>   hobo_model # Don't put anything above this
> 
>   fields do
>    name :string
>    date :date
>    time :decimal
>    timestamps
>   end
> 
>   belongs_to :project
>   belongs_to :user, :creator => true
>   belongs_to :client
> 
> > 
> 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" 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/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to