首先,感恩節快樂。路由問題,rails生成錯誤的url
所以我的問題是我的路線,我不清楚爲什麼ID參數實際上包含整個對象。 Rails的給了我這個錯誤:
user_url failed to generate from {:action=>"show", :controller=>"users", :id=>#<User id: 19, username: "Dr. Dorothy Buckridge", email: "[email protected]", crypted_password: nil, password_salt: nil, persistence_token: nil, created_at: "2009-11-10 19:38:31", updated_at: "2009-11-10 19:38:31", perishable_token: "", color: nil>}, expected: {:action=>"show", :controller=>"users"}, diff: {:id=>#<User id: 19, username: "Dr. Dorothy Buckridge", email: "[email protected]", crypted_password: nil, password_salt: nil, persistence_token: nil, created_at: "2009-11-10 19:38:31", updated_at: "2009-11-10 19:38:31", perishable_token: "", color: nil>}
在這條線上出現的錯誤:
<%= link_to recipe.user.username, recipe.user, :class => "user" %>
任何想法?它似乎應該只是爲該屬性生成對象的id
。
我的問題控制器:
def index
@recipes = Recipe.search params[:search], :field_weights => { :name => 20, :description => 10 }
end
實在看不出是什麼問題。
感恩節(不管是什麼意思)可能與編程無關。 – pavium 2009-11-26 20:10:53
真正的感恩節是近2個月前。與時俱進。 – EmFi 2009-11-26 20:14:40