Cancan, how to allow artists to edit their own

What am I doing wrong here? I am using cancan on Rails 3. In my
Ability class, I’ve got:

class Ability
include CanCan::Ability

def initialize(user)
user ||= User.new # guest user, for users who are not registered
or don’t have an account yet

if user.role? :admin
  can :manage, :all
elsif user.role? :artist
  can :read, [Artist, Painting, Video]
  can :manage, Video do |video|
    video.try(:user) == user
  end
else
  can :create, [Artist]
  can :read, :all
end

end
end

In VideosController#index, I have:

      <% if can? :update, song %>
        <div class="interaction clearfix">
          <%= link_to 'edit', '#' %>
          <%= link_to 'delete', '#', :class => 'last' %>
        </div>
      <% end %>

I get:

undefined method `user’ for :index:Symbol

By the way. I am using Devise, if that even matters

On Oct 12, 8:41pm, Christian F. [email protected]

Small code typo. In VideoController#index. It should have been:

      <% if can? :update, video %>
        <div class="interaction clearfix">
          <%= link_to 'edit', '#' %>
          <%= link_to 'delete', '#', :class => 'last' %>
        </div>
      <% end %>

On Oct 12, 9:05pm, Christian F. [email protected]

Any thoughts? Also worth noting that Video and Paintings inherit from
Media. Media is an STI

On Oct 12, 9:07pm, Christian F. [email protected]

What is the last error you got?

undefined method `user’ for :index:Symbol

does cancan expect me to have a user method in my user model or
something?

On Oct 12, 10:44pm, Christian F. [email protected]

Ok… I must have been using old cancan code. Back when I was still on
Rails 2.3.8.

The new doc says: can :manage, Painting, :artist_id => user.artist.id

Which now seems to work without any errors

On Oct 12, 10:55pm, Christian F. [email protected]