Originally Posted by ReggieB
Thanks for your help in the other thread, this one is a slightly different issue though and not related to testing.
In this particular case, I've got a table of stories already, and now a user_id attribute has been added to it. And the view file is calling for the user_id attribute, and thus throwing out errors because the majority of the stories do not already have the user_id value. So I was attempting to set the user_id value of all of the existing stories, but couldn't get it to work within a block.
I'd just noticed that I'd forgotten to stick my code in a code block, so will do it now.
I tried this within the console, but it didn't change the values of user_id at all.
Story.find(:all) do |s|
Again, the other method that I did do (reprinted for the code block), that did work was (the id=6 is just an example). But I didn't want to do this line-by-line.
Any ideas? Thanks!
PS: I did eventually just worked around it using an if/else clause to ignore the user name display if it s.user_id==nil, but I'm curious now if it is possible to deal with this for future reference.