On Jun 22, 2010, at 14:56 , Don Morrison wrote: > While I don't have an answer to your question I have some thoughts and a > suggestion. > > Putting this knowledge of the display of the data into the model seems to be > a violation of MVC in a big, big way. Although I'm not sure if you care ;-) I > was faced with some similar challenges and began using munger[1] - it was a > good find. It gave me the flexibility I needed to format data for display in > a variety of ways while keeping things separated. From your brief explanation > it seems like this might help you out.
Well, I do care a little bit, but here's what I'm thinking. I used to use a tool where my variables, particularly the array variables, were context aware. If I assigned Array A to Array B, Array B would just have the usual rows and columns in it. But if I just dropped either array down in the middle of a page, it would magically add all the table code. I think having Ruby objects that are smart enough to wrap themselves in proper HTML/XML when they're dropped onto a page just seems far too lovely to ignore. It would clear up all kinds of extra yackity-yak in my code right now. However, particularly for links, that means these pieces of data have to have more self-awareness than they currently have. One of my numbers has been coming out of the database in scientific notation, so every time I use it I have to sprintf it. If something should be a link, it would be nice if it already knew what it's primary key (or assigned record identifier) was. This has to happen while it's still inside the Sequel model. After that, it's too late. So much of my code right now is taken up with .to_html(:div, :class="blahblah"). It seems ridiculous to be retyping this over and over instead of giving all my objects that information at the get-go, then just using the commands in my code when I need to do something other than the default. I'm still tossing all this around in my head. I may end up just redefining String itself, and see if I can get most of what I want that way . . . . -- You received this message because you are subscribed to the Google Groups "sequel-talk" 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/sequel-talk?hl=en.
