Get Item data in sub-item view

Hi,

I’ve list of features.

class Feature < ActiveRecord::Base
has_many :assets, dependent: :destroy
end

and assets, that belongs to feature:

class Asset < ActiveRecord::Base
belongs_to :feature
validates :feature_id, presence: true
end

i have one sample feature in db, and a link to show assets for this
feature:

<%= link_to 'Show Assets', assets_path %>

Now, when i follow the link, list of assets is shown. Actually it is
empty,
as there are no assets in database. I need to show what feature this
assets
are belongs to (there’re no assets, but that shouldn’t make any
difference).

I’ve tried with this:

Listing Assets for <%= asset.feature.try(:engtitle) %>

getting

undefined local variable or method `asset’ for
#<#Class:0xb4ce52e8:0xb55c4440>

and this

Listing Assets for <%= @feature.try(:engtitle) %>

raising exception, but there’s definitely engtitle for this feature in
database.

What am i doing wrong?

Thanks

Listing Assets for <%= asset.feature.try(:engtitle) %>

If there are no assets, what is asset set to? Clearly it’s set to nil
right now, but what did you think it should be set to, and why?

Listing Assets for <%= @feature.try(:engtitle) %>

What is the exception being raised here?

Please show the controller so we can tell what is being set up for the
view.