當我打開一個在heroku上構建的應用程序時,當我進入註冊頁面時出現應用程序錯誤。我進入了我的heroku日誌,並發現此錯誤消息:如何解決我在Heroku上遇到的這個錯誤?
已完成500內部服務器錯誤6毫秒渲染用戶/ new.html.erb內佈局/應用程序(5.5毫秒) ActionView :: Template :: Error(undefined方法`TIME_ZONE」爲#):
這裏是我創建新用戶視圖:
<div class="row">
<div class="span6 offset4">
<%= form_for(@user) do |f| %>
<%= render 'shared/error_messages' %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :email %>
<%= f.text_field :email %>
<%= f.label :phone_number, "Your cell phone number" %>
<%= f.text_field :phone_number %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.label :password_confirmation, "Password confirmation" %>
<%= f.password_field :password_confirmation %>
<%= f.label :time_zone, "Choose your time zone" %>
<%= f.select :time_zone, [['Eastern'], ['Central'], ['Mountain'], ['Pacific']] %><br>
<%= f.submit "Create my account", class: "btn btn-large btn-primary" %>
<% end %>
什麼可能導致這個錯誤,我怎麼能去修復它?非常感謝!
def create
@user = User.new(params[:user])
if @user.save
sign_in @user
flash[:success] = "Welcome to app!"
redirect_to info_path
else
render 'new'
end
末
高清新 @user = User.new 結束
'@ user'有'time_zone'屬性嗎? – deefour 2012-07-11 17:34:16
是的。在我的用戶模型中,我有以下代碼:attr_accessible:time_zone – user1483441 2012-07-11 17:36:57
'attr_accessible:time_zone'不是':time_zone'的一個屬性定義。你可以在shell中打開'rails console'並運行u = User.new; u.time_zone'沒有收到錯誤?這在你的視圖中假定'@ user'是一個名爲'User'的模型的實例。 – deefour 2012-07-11 17:38:56