此前,我一直在铁路图西里书上跟踪,创建用户和职位,并提供一个显示职位的信息。 然而,提交人从未使用过专用资源,这似乎在铁路中非常重要,我要发现如何使用这些资源。 然而,当我根据Ruby在铁路指南中提供员额资源时,它随后打破了我的所有形式和道路。
Instead of starting over I would like change over to nested resources and in the process learn exactly what the differences are. Can anyone help with how I would go about this? Thanks for any help.
尤其是 我对如何使用饲料感到迷惑。 目前,供款——项目指旧员额。
shared/_feed_item partial
<tr>
<td class="avatar">
<%= link_to avatar_for(feed_item.user), feed_item.user %>
</td>
<td class="post">
<span class="title"><%= link_to feed_item.title, feed_item %></span><br />
<span class="content">the plot: <%= feed_item.content %></span><br />
<span class="timestamp">
Posted <%= time_ago_in_words(feed_item.created_at) %> ago.
</span>
</td>
</td>
<% if current_user?(feed_item.user) %>
<td>
<%= link_to "delete", feed_item, :method => :delete,
:confirm => "You sure?",
:title => feed_item.content %>
</td>
<% end %>
</tr>
micropost controller
class Micropost < ActiveRecord::Base
.
.
.
default_scope :order => microposts.created_at DESC
# Return microposts from the users being followed by the given user.
scope :from_users_followed_by, lambda { |user| followed_by(user) }
private
# Return an SQL condition for users followed by the given user.
# We include the user s own id as well.
def self.followed_by(user)
followed_ids = %(SELECT followed_id FROM relationships
WHERE follower_id = :user_id)
where("user_id IN (#{followed_ids}) OR user_id = :user_id",
{ :user_id => user })
end
end
http://ruby.railstutorial.org/ Chapters/user-microposts#top” rel=“nofollow” http://ruby.railstutorial.org/ Chapters/user-microposts#top。 http://ruby.railstutorial.org/ Chapters/following-users#top” rel=“nofollow” http://ruby.railstutorial.org/ Chapters/following-users#top