我一直在关注在线教程,显然我输入错误或做错了。我知道它正在尝试提供活动,但我不知道从哪里开始。
我会根据要求添加更多详细信息。
ActionView::Template::Error (Missing partial public_activity/post/_created with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}. Searched in:
* "/home/benjamin/Desktop/stukbook/app/views"
* "/home/benjamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/twitter-bootstrap-rails-d3776ddd0b89/app/views"
* "/home/benjamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.0/app/views"
):
55: <div class="panel panel-default">
56: <div class="panel-heading">Recent Activity</div>
57: <div class="panel-body">
58: <%= render_activities(@activities) %>
59: </div>
60: </div>
61: </div>
我的观点/ users / show.html:
<div class="jumbotron">
<div class="container">
<div class="row">
<div class="col-md-4">
<%= gravatar_tag @user.email, size: 200 %>
</div>
<div class="col-md-4">
<h3><%= @user.username %></h3>
<p>Age: <%= @user.age %></p>
<p>Gender: <%= @user.gender %></p>
</div>
<div class="col-md-4">
<h3>Who am I</h3>
<small><%= @user.bio %></small>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<!-- Friend Zone -->
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-heading">Friends (<%= @user.active_friends.size %>)
</div>
<div class="panel-body">
<% @user.active_friends.last(16).each do |user| %>
<%= link_to user_path(user.username) do %>
<%= gravatar_tag user.email, size: 40 %>
<% end %>
<% end %>
</div>
</div>
</div>
<!-- Post Zone -->
<div class="col-md-6">
<% if current_user && current_user == @user %>
<%= render "posts/form" %>
<% end %>
<%= render @posts %>
</div>
<!-- Profile Activity -->
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-heading">Recent Activity</div>
<div class="panel-body">
<%= render_activities(@activities) %>
</div>
</div>
</div>
</div>
</div>
用户控制器:
class UsersController < ApplicationController
before_action :authenticate_user!, only:[:index]
before_action :set_user, only:[:show]
def index
case params[:people] when "friends"
@users = current_user.active_friends
when "requests"
@users = current_user.pending_friend_requests_from.map(&:user)
when "pending"
@users = current_user.pending_friend_requests_to.map(&:friend)
else
@users = User.where.not(id: current_user.id)
end
end
def show
@post = Post.new
@posts = @user.posts.order('created_at DESC')
@activities = PublicActivity::Activity.where(owner_id: @user.id) + PublicActivity::Activity.where(recipient_id: @user.id)
end
private
def set_user
@user = User.find_by(username: params[:id])
end
end
答案 0 :(得分:1)
如果你看错误
ActionView::Template::Error (Missing partial public_activity/post/_created with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}. Searched in:
* "/home/benjamin/Desktop/stukbook/app/views"
* "/home/benjamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/twitter-bootstrap-rails-d3776ddd0b89/app/views"
* "/home/benjamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.0/app/views"
):
第一行是解释调试错误所需的一切。
Missing partial public_activity/post/_created
这一行
<%= render_activities(@activities) %>
正在下面的目录路径中查找标题为&#34; _created&#34;
的文件public_activity/post/_created
如果该路径和文件不存在但您希望使用您设置的路径创建所需的文件夹(public_activity将是第一个,post将在其中,然后在post文件夹中,您将需要该文件_created.html.erb)需要开始下划线。