I haven't done anything unusual.
- created rails app with 'rails test'
- created mysql database & table (via phpMyAdmin)
- edited database.yml
- using text editor created app/model/product.rb using your code
- same for app/controller/admin_controller.rb
- started webrick using './script/server'
- loaded http://localhost:3000/admin in browser
That's it. Also you can try to do the same thing from console.
Code:
basti@bali:test$ ./script/console
Loading development environment.
>> p = Product.new
=> #<Product:0xb741afe8 @new_record=true, @attributes={"image_url"=>"", "title"=>"", "description"=>""}>
>> p.save
=> false
>> p.title = 'test'
=> "test"
>> p.image_url = 'test'
=> "test"
>> p.description = 'test'
=> "test"
>> p.save
=> true
As you can see when I first tried to save the model it returned false because validation failed.
Bookmarks