In my Ruby app I have two classes Event and Company, such that Event...
belongs_to :company
Then in event.jst.eco I have the following code...
<span><%= @event.get'company_id'=></span>
However instead of returning the company_id I want to return the company name which is an attribute of the parent class Company.
I would have thought it was something like...
<%= @event.company.get('name') %>
but that just gives me...
ExecJS::ProgramError in Site#index
How can I achieve this?
You should write as :-
<span><%= @event.company.name =></span>
As per the belongs_to association inside the Event model, it must have a method called #company, which will give you the associated Company object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With