WEB ruby on rails question

Discussion in 'OT Technology' started by durondude, Oct 30, 2009.

  1. durondude

    durondude OT Addict

    Joined:
    May 7, 2001
    Messages:
    24,061
    Likes Received:
    5
    Location:
    Earth, The Planet
    I have an hash table
    Code:
    p[:ticket][:id]
    p[:ticket][:name]
    p[:ticket][:pid]
    
    when I call this code
    Code:
    t = Ticket.first(p[:ticket][:id])
    t.update_attributes!(p[:ticket])
    
    only 'id' and 'name' get updated, 'pid' gets blanked out
    Tickets table has those 3 columns and the code below works fine so the values are stored in the initial p hash table
    Code:
    t = Ticket.first(p[:ticket][:id])
    t.update_attributes!(p[:ticket])
    t.update_attribute(:pid, p[:ticket][:pid])
    
    Where did I fuck up?:dunno:
     
    Last edited: Oct 31, 2009
  2. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    is this coming from an .erb template?

    you should probably rename
    Code:
    p[:ticket][:pid]  to p[:ticket][:priority_id] 
    since it looks like that is the real column name

    your erb template prob looks like this:
    Code:
    <%= f.select @ticket, :pid %>
    
    when it should look like
    Code:
    <%= f.select @ticket, :priority_id %>
    
     
  3. durondude

    durondude OT Addict

    Joined:
    May 7, 2001
    Messages:
    24,061
    Likes Received:
    5
    Location:
    Earth, The Planet
    sorry i shortened the names for OT. I think it was a plugin i used. after i added some validate_presence_of fields, they started working. Also i had to make sure all my models were set up correctly for the one to many relationships

    i was using has_one when i should have been using belongs_to

    thanks!!!
     

Share This Page