开发者

Partials for HABTM

I have the following models:

user.rb

  has_and_belongs_to_many :comps 

comp.rb

  has_and_belongs_to_many :users

And my comps_controller.rb is:

  def index
    @user = User.find(current_user.id)    
    @comps = @user.comps
  end

and my comps/index file is:

    <%= render @comps %>

and my partial comps/_comp file is:

<tr>
<span class="content"><%= comp.name %></span>
  <td>
  <%= link_to "delete", com开发者_Python百科p, :method => :delete,
                              :confirm => "You sure?",
                              :title => comp.name %>
  </td>
</tr>

However, I get the error "undefined method `model_name' for NilClass:Class"

I'm not sure what is causing this

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜