title: rails post path issue
body: <p>I've an issue with the paths in the views and I don't know how to solve it.
  I've "categories" that has_many "posts" and "posts" that belongs_to "categories".</p>
  
  <p>1.- I want to show on home page the truncate last post of an specific category (the ID number "1"). Then I want that post to link to the show post path but I get this error:</p>
  
  <p>"Unknow Action
  The action 'index' could not be found for PostsController"</p>
  
  <p>I think I've my paths wrong because I don't need the index view because I'm only going to show that specific post. So, I think that category_posts_path(@last_post) is not the right path (I don't know where to look for more info about making the route path in the views...). Actually, the browser is showing me that is looking for the "2" category when it is a post of the "1" category...? What am I doing wrong?
  This is the browser route:</p>
  
  <pre><code>http://localhost:3000/en/categories/2/posts
  </code></pre>
  
  <p>This is my views/categories/home.html.erb file:</p>
  
  <pre><code>&lt;div class="post_details"&gt;
   &lt;h2&gt;&lt;%= @last_post.title %&gt;&lt;/h2&gt;
   &lt;%= image_tag @last_post.image(:header), class: "post_image" %&gt;
   &lt;p&gt;&lt;%= truncate @last_post.body, length: 100 %&gt;&lt;/p&gt;
   &lt;p class="button"&gt;&lt;%= link_to "READ MORE", category_posts_path(@last_post) %&gt;&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>2.- I have another path problem in the views/categories/show.html.erb file. I have a loop to show all the post of one specific category, but when I link in some post (to show it) there is the "index" error again:</p>
  
  <p>"Unknow action
  The action 'index' could not be found for PostsController"</p>
  
  <p>This is the browser route:</p>
  
  <pre><code>http://localhost:3000/en/categories/1/posts
  </code></pre>
  
  <p>This is the views/categories/show.html.erb file:</p>
  
  
  
  <pre><code>&lt;div class="post_details"&gt;
      &lt;h2&gt;&lt;%= link_to post.title, category_posts_path(post) %&gt;&lt;/h2&gt;
      &lt;%= image_tag post.image(:header), class: "post_image" %&gt;
      &lt;p&gt;&lt;%= post.body %&gt;&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  
  
  <p>This is the categories_controller.rb file:</p>
  
  <pre><code>class CategoriesController &lt; ApplicationController
  
    before_action :get_categories
  
    def index
  
    end
  
    def show
  
      @category = Category.find(params[:id])
  
    end
  
    def home
      if params[:set_locale]
          redirect_to root_url(locale: params[:set_locale])
      else
  
        @category = Category.find_by_id(1)
  
        @last_post = @category.posts.order("created_at desc").first
  
      end
    end
  
    def get_categories
      @categories = Category.all.order("rank asc, name asc")    
    end
  
  end
  </code></pre>
  
  <p>This is my posts_controller.rb file:</p>
  
  <pre><code>class PostsController &lt; ApplicationController
  
  
      def show
          @category = Category.find(params[:category_id])
          @post = @category.posts.find(params[:id])
      end
  
  
  end
  </code></pre>
  
  <p>This is my route.rb file:</p>
  
  <pre><code>  scope '(:locale)' do
  
      resources :categories do
        resources :posts
      end
  
      resources :contacts
  
      root 'categories#home'
  
      get "/contact" =&gt; "contacts#new"
  
      # static pages
      get "/investment" =&gt; "contents#investment"
      get "/partner-with-us" =&gt; "contents#partner", as: "partner"
      get "/our-companies" =&gt; "contents#companies", as: "companies"
      get "/site-map" =&gt; "contents#sitemap", as: "sitemap"
      get "/terms-and-conditions" =&gt; "contents#terms", as: "terms"
      get "/privacy" =&gt; "contents#privacy"
  
    end
  </code></pre>