On Dec 23, 2009, at 1:29 PM, andrew hill wrote:

> hi folks,
>
> i'm trying to figure out how to display different data on the show  
> record page than the table display / search page.
> e.g. i've got a model called "guitar" that produces an output like  
> this when i list / search on it:
[snip]
> those two or three-letter codes are "factory" codes in my guitar  
> database table, and i'd like to leave them be, so people can search  
> using a combo of standard codes.
>
> i've got another table/model called "factorycodes" which only has 2  
> columns, one with the 3-letter code, and the other with a plain  
> english translation (e.g. WHT is White)
>
> when i click on the guitar serial number under the "Guitar" column,  
> though, i'd like to do some sort of join so that the individual  
> record listing replaces the column values with ones from the other  
> table, e.g. modify this below:
>
[snip]
> anyone have a suggestion how to do this?  i've been trying various  
> "through" syntax but not 100% sure what i'm doing, as i can only  
> seem to break the lookups :)

There are some fancy options for associations like :primary_key that  
*might* be able to help here, but the support is lacking in Rails at  
the moment (still some latent bugs with preloading and has_one).

But I'm thinking you might be better off using a rich-type sort of  
thing to handle this; it would also help when it comes time to input  
data, as the dropdowns could show English options rather than codes.  
Not sure exactly how it would work, since the standard enum_string  
stuff only works with options known at compile time. Maybe take a look  
at how the Agility tutorial handles DB-powered story status?

Hope this helps!

--Matt Jones



--

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