0

I am a relatively new web programmer and I'm trying to add this code on top of the /omrails tutorial. I'm able to get the gem acts-as-taggable-on to work until I input this code in pins/index.html.erb:

<%= render 'pages/home' %>

<div id="pins">
  <%= render @pins %>
  <p>Tags: <%= pin.tag_list.map { |t| link_to t, tag_path(t) }.join(', ') %></p>
</div>

<%= will_paginate @pins %>

and this into routes.rb:

  get 'tags/:tag', to: 'pins#index', as: :tag
  resources :pins
  root to: 'pins#index'

Am I doing something wrong or is this code obsolete in Rails 3 because I am worried I used an older example from the original RailsCast? I tried searching but didn't appear to come across the exact same issue. I receive a NameError in Pins#index going to line 5, which is the long line starting with the p-tag in the first chunk of code.

Any help would be appreciated.

Edit to replicate error message:

A link to an image of the error message on imgur because I do not have the reputation to post an image and am not sure how to best enter the error into stackoverflow.

Edit 2 to add Pins Controller index method:

def index
@pins = Pin.order("created_at desc").page(params[:page]).per_page(20)

respond_to do |format|
  format.html # index.html.erb
  format.json { render json: @pins }
  format.js
end
end
harrisongill
  • 113
  • 1
  • 10
  • Please, can you post the full error message. Is the pin in that line defined/passed to this view? I think the problem lies in `<%= pin.tag_list %>` – vee Jun 11 '13 at 02:32
  • I added a link to a screenshot of the error message because I wasn't sure how to best post it. Thank you in advance for any help you can provide @vinodadhikary. In the example, which was handling an articles class, similar code appeared `article.tag_list`. Additionally, adding `raw` does not fix the issue. – harrisongill Jun 11 '13 at 02:53
  • problem lies elsewhere not at the `raw`. Please post the index method definition of your PinsController. By the way you should look at [http://stackoverflow.com/editing-help#comment-formatting](http://stackoverflow.com/editing-help#comment-formatting). – vee Jun 11 '13 at 03:24
  • @vinodadhikary, I've added the PinsController. I've taken a look also at the formatting and will be appending edits onto the bottom as code to try to follow the conventions and document forming standards. – harrisongill Jun 11 '13 at 03:49
  • 1
    `pin` variable is not defined where you try to get access to it. You should put paragraph with tags in _pin.html.erb. – Marek Lipka Jun 11 '13 at 06:41
  • Thank you @MarekLipka, that was indeed the issue. I'm think this arises because I was rendering from the partial and forgot to take that into consideration. As mentioned, still pretty new at this. Thank you! – harrisongill Jun 11 '13 at 07:40

0 Answers0