I am working in rails 3.2.1 app.Below are my model name and their associations,
Model language_name:
class LanguageName < ActiveRecord::Base
attr_accessible :language_name
end
language_name table:
Model news_subscription
class NewsSubscription < ActiveRecord::Base
belongs_to :language_name
attr_accessible :id, :user_id, :language_name_id, :subscriber_id
end
news_subscription table:
Controller:
def edit
@news_subscription = NewsSubscription.where(:user_id => id).all
end
views
= @news_subscription.language_name_id
I want to display the language_name
of language_name_id
in news_subscription
table. Currently When i tried with = @news_subscription.language_name_id.language
it is showing "undefined method language
" and @news_subscription.language_name_id
showing the id alone.
I am newly learning RoR, please help me.
Aucun commentaire:
Enregistrer un commentaire