On Nov 24, 2007 2:17 PM, Adinda Praditya <[EMAIL PROTECTED]> wrote:
> Dan tentu saja error krn yang diminta dari address_zip.length adalah method
> length, yang mana itu tidak ada. Pertanyaan saya:
oops sorry i forgot to comment this :-)
length tentu adalah metode yang ada. if you saw such error: Undefined
length method for nil, itu adalah karena tiada length method
diperuntukkan kepada nil bukan karena metode length di ruby tidak ada.
you can check with this from your Terminal or from your Browser[1]
ri -f bs -T String.length
ri -f bs -T Array.size
lantas if you ask me why your address_zip was considered to be nil by
rails? coba cek lagi apakah benar sudah ada field yang diinginkan di
model ybs (mis. user). cek lihat di file-file migrationnya apakah
sudah benar, kalau sudah benar tapi ternyata sewaktu Anda spec dengan
perintah kurang lebih begini di spec you:
spec/models/user_spec.rb
describe User do
it "should have zip" do
User.should respond_to('zip')
end
it "should give error if user only gives less than 5 characters to
the zip field" do
create_user(:zip => 'x').should_not be_valid
end
it "should give error if user gives more than 6 characters to the
zip field" do
create_user(:zip => '1234567').should_not be_valid
end
end
kalau masih ada merah-merah pertanda failure spec nya coba lagi
periksa di script/about apakah ini sudah merupakan rails schema
terakhir sesuai file migration yang sudah you check kebenarannya ...
bila sudah, lalu terlihat fine-fine saja, coba ingat-ingat mungkin
sebelum-sebelumnya you usil utak atik modified your migration file ,
ex, added one field here, one field there, remove it here, remove
there... *only for development and learning process* you can safely
run this from your terminal:
rake db:migrate VERSION=0
rake db:migrate
rake db:test:purge
rake db:test:prepare
wah dari atas bila masih error juga, wah waah berarti memang belum
diberikan perintah ini
rake db:create
untuk melakukan pembuatan database sesuai yang didefine di file
config/database.yml
# looks like it's too dramatized though just in case, buddy -_-
Links:
http://www.rubyinside.com/railsbrain-fast-ajax-powered-rails-documentation-482.html
http://www.gotapi.com/html
http://del.icio.us/search/?fr=del_icio_us&p=ruby+api+documentation+ajax&type=all
--
Arie | http://linkedin.com/in/ariekeren | http://profile.to/ariekeren/
http://ariekusumaatmaja.wordpress.com | http://groups.yahoo.com/groups/id-ruby
oops