更新: 檢查控制檯,很多用戶實際上將進入數據庫,還是出現該錯誤信息!Rails的:「電子郵件已經採取」每一個電子郵件,我進入
即使是更大的問題,你會發現我有一個重定向到root_path成功保存到數據庫。它永遠不會去那裏。這是日誌。如果它節省了,它有時會轉到show動作,但實際上有一段時間,瀏覽器似乎卡住了,所有東西都會變成空白,我必須點擊地址字段才能將其展示到show.index.html。
Redirected to http://localhost:3000root_path
Completed 302 Found in 34ms
[2012-01-08 18:08:27] ERROR URI::InvalidURIError: the scheme http does not accept registry part: localhost:3000root_path (or bad hostname?)
/Users/mel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/uri/generic.rb:746:in `rescue in merge'
/Users/me/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/uri/generic.rb:743:in `merge'
/Users/me/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpresponse.rb:163:in `setup_header'
/Users/me/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpresponse.rb:101:in `send_response'
/Users/me/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:86:in `run'
/Users/me/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
原題:
我創建一個表單供用戶通過註冊來贏取iPad。它有兩個字段,電子郵件和名稱。 當我提交表單,我不斷收到同樣的錯誤消息,不管是什麼我的電子郵件進入
1 error prohibited this from being saved:
There were problems with the following fields:
Email has already been taken
奇怪的是,當我調試參數,可以就說明我進入任何新的電子郵件地址。
utf8: "\xE2\x9C\x93"
authenticity_token: UgkHFLBfKYM2tZ11u6ItWvPS5XeTIMhFuJDwvhgqe30=
ipad: !map:ActiveSupport::HashWithIndifferentAccess
name: Amy
email: [email protected]
commit: Sign up
action: create
controller: ipads
任何人有什麼想法?我有點小白......
我只是將此代碼添加到恩基博客我做on Rails的...
我有我的ipad.rb模型此驗證(筆記,我有在我只是在形式忽略了遷移的Twitter地址欄)
attr_accessible :name, :email, :twitter
validates :name, :presence => true,
:length => { :maximum => 50 }
validates :email, :presence => true,
:uniqueness => true
這是我ipads_controller.rb
class IpadsController < ApplicationController
def new
@ipad = Ipad.new
@title = "iPad Contest"
end
def create
@ipad = Ipad.new(params[:ipad])
if @ipad.save
redirect_to 'root_path'
else
@title = "Poo"
render 'new'
end
end
end
這是我的new.html。 erb
<h1>Win an iPad</h1>
<%= @title %>
<h1>Sign up for iPad</h1>
<%= form_for(@ipad) do |f| %>
<%= render 'shared/errror_messages' %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :email %><br />
<%= f.text_field :email %>
</div>
<div class="actions">
<%= f.submit "Sign up" %>
</div>
<% end %>
<%= debug params %>
你在你的模型中包含':email' at'attr_accessible'嗎? – sscirrus 2012-01-09 01:45:05
是的,我做到了。我會更新OP。 attr_accessible:name,:email,:twitter – Leahcim 2012-01-09 01:50:33
錯誤信息實際上是在用戶模型上,而不是在iPad上的模型 '1錯誤禁止這個**用戶**被保存:' 你會更新用戶模型涉及到iPad的型號? – 2012-01-09 02:02:21