#rubyonrails - Wed 28 Mar 2007 between 00:01 and 00:15

Jumb0GaryKing: did you get your problem resolved?
GaryKingJumb0: nope
Bongo`GaryKing: What's your problem?
actionBongo` just got on
Bongo`just got on
GaryKingBongo`: If a field is empty when saving, then I don't want to save that particular field. And I want to do this in the model.
Jumb0GaryKing: here's what i'm thinking... the update_attributes method takes an array parameter, if you check in your model if the password is blank, you can exclude that from the array and use the update_attributes. if the password isn't in the array, it will not be updated.
Bongo`well, if your field is empty (nil?) nothing will be saved?
GaryKingBongo`: yep
Jumb0Bongo`: that's what he wants.
stixljumb0: the session[intended_action] shows the right thing. Somehow my if statement doesn't seem to be working for some reason. I suspect I'm not using the session correctly.
Bongo`GaryKing: Create a mhod. field_blank?; !field_Name.blank?; end
Jumb0stixl: i'm gonna paste what i use. I don't think you should add a session variable to indicate if the session is timed out...that just doesn't make sense. reason: if the session is timed out, the timedout session var won't be there to tell you that...gonna make a pastie for you. 1 ssec
GaryKingBongo`: yes, that's getting somewhere, but where does it go? and please elaborate. could you paste to pastie? it's been 2 hrs
Bongo`Yeah, it's getting late here 5:00, i mnot even sure my brain understand what you want. Let me think for a sec
Jumb0stixl: take a look at this http://pastie.caboo.se/49968
Bongo`GaryKing: So you have some sort of validation for a field, and if that field is empty you wanna skip the validation?
GaryKingBongo`: It's a password and password confirmation field on a 'update profile' page.
Jumb0GaryKing: Just don't include the password in your array. if this is an "edit account page" and the user already has a password then leaving out the password from the array will prevent it from being updated...
stixljumb0: Aha! u hit the nail there. I didn't even think that the session has already timed out and therefore no more session. I'll take a look at your codes. Many thanks.. i hv been working on this problem for hours!!
GaryKingBongo`: I'm saving the fields by doing @blogger.update_attributes params[:blogger] and it works great but if password and password confirmatino are empty, then the password will be set to ''
Jumb0lol lookie lookie! i helped someone
Jumb0GaryKing: did you try what I said?
GaryKingJumb0: hm, now I understand what you mean
Jumb0: except I don't know how to remove items from an array
Jumb0GaryKing: that should work just fine
redmonkanyone here have experience getting a an app running on site5?
GaryKingSo, How do I remove an item from a hash?
Jumb0GaryKing: array.delete(obj)
Jumb0GaryKing: here are the array methods available in ruby http://www.ruby-doc.org/core/classes/Array.html
GaryKingI know where to find them. just getting tired of working in rails
Jumb0GaryKing: tired of rails? omg have you ever worked with any other web dev framework?
GaryKingAnd I'm tired of them, too.
Bongo`GaryKing: DOn't you have any validate_lenth_of :password?
GaryKingBongo`: no
GaryKingBongo`: but it doesn't make sense if I don't mind it be 0
Jumb0If anyone cares, handling user authentication is best shown in the Rails Recipe PDF/Book. Found here: http://www.pragmaticprogrammer.com/titles/fr_rr/

Page: 2 9 16 23 30 37 44 51 58 65 72 79 86 93 100 107 114 121