SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Formerly known as RockNRollPig Shpigford's Avatar
    Join Date
    Dec 2002
    Location
    Denver, CO
    Posts
    2,877
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with validates_presence_of

    I'm getting the following error:
    Code:
    Validation failed: Price can't be blank, Title can't be blank, Description can't be blank, Sku can't be blank
    It's not returning that info to error_messages_for...it's just throwing a "fatal" error.

    Price, Title, Descripiton, and Sku are definitely getting passed though:
    Code:
    {"commit"=>"Add Product",
     "product"=>{"price"=>"29.99",
     "uploaded_data"=>#<File:/var/folders/QD/QD01ZVfhGTyzWMymNc3jeE+++TI/-Tmp-/CGI15577-5>,
     "title"=>"Petmate Durabed Large",
     "product_category_id"=>"6",
     "description"=>"Durabed is made from metal tubes and durable fabric cover. It is not a pillow,
     nor a basket. It's a frame bed. High side walls to cuddle up against. Padded board keeps the 
    platform straight to protect the dog's spine. Rectangular design saves space and holds 30 to 75 pounds. 
    This bed is approximately 6 to 7 inches off the floor. Machine washable. This is a large size measuring 25\" x 32\".",
     "sku"=>"B0002DI5FW"},
     "authenticity_token"=>"75161cd9f1b84156c3ed996430fc25c2e43d5d10"}
    Any ideas why validates_presence_of would be doing this? validates_presence_of works fine in other models.

  2. #2
    SitePoint Enthusiast AllTom's Avatar
    Join Date
    Feb 2008
    Location
    Wherever danger lies...
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Calling a method like save! or create! with a bang will cause it to throw errors instead of simply returning false.

    The hash that you pasted is params, right? And you initialized a Product with params["product"] when you got the error? Can you provide the code surrounding this? What is the fatal error, and what is the method from which it is thrown?
    There are some things you shouldn't try to code at home.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •