Railstutorial.org书,更改为嵌套路线

| 嗨,我一直在遵循Rails教程书,创建用户和帖子以及显示帖子的提要。但是,作者从未使用过嵌套资源,嵌套资源在rails中似乎非常重要,我想发现如何自己使用它们。但是,当我根据Ruby on Rails指南嵌套post资源时,它随后破坏了我的所有表单和路径。 与其从头开始,我不希望切换到嵌套资源,并在此过程中确切了解差异。谁能帮我解决这个问题?谢谢你的帮助。 特别是我对如何处理提要感到困惑。当前feed_item调用旧的post_path。 共享/ _feed_item部分
<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>
微站控制器
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中的第11.3.3节开始的,并在本章的12.3中为实物构建的http://ruby.railstutorial.org/chapters/following -users#top     
已邀请:
以下是一些可以帮助您入门的链接:   railscasts.com/episodes/139-nested-resources   railscasts.com/episodes/196-nested-model-form-part-1   railscasts.com/episodes/197-nested-model-form-part-2     

要回复问题请先登录注册