Ok不诚实,即没有花很多时间来寻找解决办法,但我的儿子如何保持我的注意力。 我只想问一个问题,因为问题似乎很简单,但迄今却 st。
因此,为了保持简单的说法,我有用户(w/model)和家庭控制者,家庭是根本的路线。
在根基目录中,我希望能够看到用户使用阿加克斯在主页上用一个部分更新员额清单的所有员额。
在用户 控制员 我有一个叫的用户牌。
def userposts
@user = User.find_by_id(params[:id])
@userposts = @user.posts.all(:order => "created_at DESC")
respond_to do |format|
format.js { @userposts}
end
end
And in my view I have
<p id="aboutuser">
<% if @user.about? %>
<%= " " + @user.id.to_s %>
<% else %>
User has not yet filled this out.
<% end %>
</p>
<h3 id="authpostlink">
<%= link_to "List of all posts", user_userposts_path(@user.id), :id => @user.id, :remote => true %>
</h3>
我的错误如下:
Started GET "/users/2/userposts" for 127.0.0.1 at Sun Jan 15 13:36:23 -0600 2012 Processing by UsersController#userposts as JS Parameters: {"user_id"=>"2"} User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1 Completed 500 Internal Server Error in 1ms
NoMethodError (undefined method
posts for nil:NilClass):
userposts
app/controllers/users_controller.rb:27:inRendered /home/n0de/.rvm/gems/ree-1.8.7-2011.03/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.8ms) Rendered /home/n0de/.rvm/gems/ree-1.8.7-2011.03/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.8ms) Rendered /home/n0de/.rvm/gems/ree-1.8.7-2011.03/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (3.2ms)
我确实认识到,我没有张贴<代码>_show.js.erb。 档案要求采取行动更新零件,但根据错误信息,这一过程似乎如此。