I'm trying to figure out how to list my users by a certain string. In my app I have `Artist` who have one `Artist_profile` through `has_one`. In my `Artist_profile`, I have `genre`, which is what I'm trying to sort them out by. I do have it working at the moment with an if statement, but it looks through every single `Artist` and picks out the ones with the match. For example:

```
<% @artists.each do |artist| if artist.artist_profile.genre == "Rock" %>
  <li><%= artist.id %></li>
<% end %>

```

I'm trying to get it something more like this, so it's less strain on my database:

```
<% @artists.rock.each do |artist| %>
  <li><%= artist.id %></li>
<% end %>

```

and my model:

```
def self.rock
  where(Artist.artist_profile.genre == "Rock")
end

```

However I get this error:

```
undefined method `artist_profile' for #<Class:0x6962940>

```

I think it's something to do with the `has_one` method, but can't seem to get this to work no matter what I try.