我嘗試了rails 3,剛開始一個新項目。以下是我輸入的全部內容。未創建的對象顯示在頁面上,並且重定向失敗
rails new todo
cd todo
bundle install
rails generate scaffold Task done:boolean task:text created:date
rake db:migrate
rails server&
firefox 0.0.0:3000/tasks&
在0.0.0:3000/tasks/new
頁,我填寫了一些字段的值,單擊該按鈕來創建一個新task
。它用空白頁重定向到0.0.0:3000/tasks
。當我手動重新加載頁面時,即使應該只有一個,它也會顯示八個tasks
。
當我再單擊show
,edit
或destroy
,它說,對於例如爲:ActiveRecord::RecordNotFound in TasksController#show
Couldn't find Task with ID=1
。
當我重新加載到0.0.0:3000/tasks
時,所有八個tasks
仍然存在。
這有什麼問題?我的電腦上的導軌損壞了嗎?
登錄
當我點擊 '創建任務',通過這樣的folowed終端顯示
Started GET "/tasks/new" for 127.0.0.1 at 2011-05-13 22:04:26 -0400
Processing by TasksController#new as HTML Rendered tasks/_form.html.erb (6.7ms) Rendered tasks/new.html.erb within layouts/application (25.3ms) Completed 200 OK in 35ms (Views: 27.9ms | ActiveRecord: 0.0ms)
重複x
八次tasks/x
不同從1
到8
:
Started POST "/tasks" for 127.0.0.1 at 2011-05-13 22:04:32 -0400 Processing by TasksController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"QZHWWyE5KcZhLrzRhB4Fgnl9HGiQqNkn17O4CUfUUJU=", "task"=>{"done"=>"0", "task"=>"test\r\n", "created(1i)"=>"2011", "created(2i)"=>"5", "created(3i)"=>"14"}, "commit"=>"Create Task"} AREL (0.2ms) INSERT INTO "tasks" ("done", "task", "created", "created_at", "updated_at") VALUES ('f', 'test ', '2011-05-14', '2011-05-14 02:04:32.065805', '2011-05-14 02:04:32.065805') Redirected to http://0.0.0:3000/tasks/2 Completed 302 Found in 17ms [2011-05-13 22:04:32] ERROR URI::InvalidURIError: the scheme http does not accept registry part: 0.0.0:3000 (or bad hostname?) /usr/local/lib/ruby/1.9.1/uri/generic.rb:746:inrescue in merge' /usr/local/lib/ruby/1.9.1/uri/generic.rb:743:in
merge' /usr/local/lib/ruby/1.9.1/webrick/httpresponse.rb:163:insetup_header' /usr/local/lib/ruby/1.9.1/webrick/httpresponse.rb:101:in
send_response' /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:86:inrun' /usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in
block in start_thread'
的做什麼'當您單擊「創建任務」 development.log'說明了什麼? –
@dmarkow我添加了日誌。 – sawa