I’ve written a helper for my user model in user_helper.rb
module UserHelper
def get_array_of_names_and_user_ids
User.all(&:first_name) + User.all.map(&:user_id)
end
end
Unfortunately when I type in
<div class="field">
<%= f.label :assignee, "Assigned to" %>
<%= select(:task, :assignee_id, User.get_array_of_names_and_user_ids )%>
</div>
It can’t see it. Where am I going wrong? I’m using devise.
You’re close. The helper doesn’t become a class method like that — it becomes accessible as a method in your views. Just simply call
get_array_of_names_and_user_ids.