首先,感恩节快乐。路由问题,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