开发者

Partials for HABTM

开发者 https://www.devze.com 2023-04-10 16:32 出处:网络
I have the following models: user.rb has_and_belongs_to_many :comps comp.rb has_and_belongs_to_many :users

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

精彩评论

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

关注公众号