所以我有这个 2 步 Twitter 登录,在用户必须输入他的电子邮件的页面上,我得到一个未定义的方法错误。
我的表格:
<%= simple_form_for(@user, :as => "user", :url => account_create_path, :html => {:class => "form-inline"}) do |f| %>
<%= f.input :email, :placeholder => User.human_attribute_name(:email), :class => "input-medium" %>
<%= f.submit "Finish registration", :class => "btn btn-small" %>
<% end %>
我认为这是一个语法问题,但由于我对 Rails 还很陌生,所以我不知道出了什么问题。谷歌也不会告诉我:)
我的Accounts_controller.rb:
def create
data = session["devise.omniauth_data"]
data[:email] = params[:user][:email]
user = User.find_for_twitter_oauth(data)
user.email = data[:email]
if user.save
flash[:notice] = I18n.t "devise.registrations.signed_up_but_unconfirmed"
redirect_to root_path
else
flash[:error] = I18n.t "devise.omniauth_callbacks.failure",
:kind => data[:provider].titleize,
:reason => user.errors.full_messages.first
render "users/omniauth_callbacks/add_email"
end
end