Search code examples
ruby-on-railssimple-formselectlistobject-address

Select field in Rails simple form gem returns object (hex) address


I am using a has_many through relationship for project_assignment, expence_types and assignment_expences tables. I my simple form for adding new expences, i have:

<%= f.association :project_assignment, prompt: 'choose...', collection: ProjectAssignment.where('active = ?', true).order(:task) %>

This should show task description from field task (table project_assignments) but it returns an object address.
I have another example on this same form:

<%= f.association :expence_type, prompt: 'choose...', collection: ExpenceType.where('active = ?', true).order(:name), right_column_html: { class: 'col-md-1 col-lg-1' } %>

That works just fine. Shows the name. I've read that it shows addresses when converting object to string, but I can't make this to work. Any help would be appreciated.


Solution

  • Please check that your ProductAssignment model defines a to_s instance method, returning the attribute you want to display.