#rubyonrails - Sun 15 Apr 2007 between 00:00 and 00:15

NY Lost Funds



aroonirellik: looks like h() does this: http://railsruby.blogspot.com/2006/02/h-htmlescape_17.html
rellikarooni, (and lonny), as luck would have it, it's 'sanitize(html)'
lonnyrellik: Ahhh... I see now.
aroonirellik: ok but how can i get new lines?
lonnyelasticdog: Is there anything sensitive about what you want to cache? If not, a simple way would be to use session.
rellikarooni, the API for sanitize doesn't say if it strips out newlines or not.. if it does, you'll have to write your own sanitizer, like the link that you posted
elasticdoglonny: nope, it's not sensitive, but it's a derived attribute in the model, not really session related
lonnyelasticdog: It doesn't have to be session-specific. Session is just a hash. It is generally recommended to keep it small, but you can use it for your own stuff if you want.
elasticdogbasically I a project has_many tasks, and I want to be able to have a task.long_name => "Project Title - Task Name"
but the way it is now, it does a SQL query every time I ask for task.long_name because it is looking up the project title
myobiei got a .each that is only performing the first go around if a perform a #delete on a has_many :through association...if i comment the #delete out, it loops like it should...any ideas how this is possible?
aroonirellik: can i strip out the new lines, and then put them back in?
lonnyelasticdog: Right. Well... the simplest ways that occur to me are either using a session variable, or a global variable. Both can be used for cheap "caching".
rellikarooni, if it strips them out like this: gsub(/\n/, "") then they're just gone
aroonirellik: we'll i'm saying just add them back in
lonnyelasticdog: Either will be preserved until you specifically change them... or until a new session occurs, which is probably okay.
arooniafter i stripped it ... ?
rellik: and should i be inserting '\n'
or <br/>
lonnymyobie: Yeah. When you do a delete it changes the contents of the collection. That messes up the .each.
myobielonny: even if i am doing .each on a different object than i am deleting?
lonnymyobie: Uh, no. I thought that was what you were doing. 'Scuse.
rellikarooni, \n is for newlines in strings, <br /> is newlines in html
myobielonny: i do a array = model.has_many_models
aroonirellik: well i understand that... but if have a string i want to be on a new line when i display it in a view
myobielonny: then array.each do
arooniwhich should i use?
myobielonny: is it possible that the variable i created is just pointing to the model structure and not holding it's own copy?
lonnymyobie: Okay... array.each do |something| ... Then, are you deleting the "something"?
rellikarooni, your string should have \n's.. that's MVC.. then, in your view you call a helper my_sanitizer(html) which does the sanitizing/newline-changing
actionmyobie pasted http://pastie.textmate.org/53925
myobiepasted http://pastie.textmate.org/53925
lonny: check that pastie
aroonirellik: which one of these is newline: s.to_s.gsub(/&/n, '&').gsub(/\"/n, '"').gsub(/>/n, '>').gsub(/</n, '<')
is it the second gsub?
lonnymyobie: Yeah... even if it is only an array of pointers, you are still deleting array elements, so you mess up the .each
myobielonny: how would i handle this situation then?
lonny: any ideas are wlecome?
lonnymyobie: Make an array of the locations you want to mark, then delete them after you finish the .each.
rellikarooni, no the second gsub is for \"
myobielonny: can i do a #delete([1,2,3])?

Page: 2 9 16 23 30 37 44 51 

IrcArchive

NY Lost Funds