Friday, September 20, 2024 12:07:55 AM
> settings

Customize


Authenticate

> communities_helper.rb
# frozen_string_literal: true

module CommunitiesHelper
  def options_for_communities
    communities = [OpenStruct.new(label: "", value: communities_path)]

    communities +=
      @communities.map do |community|
        OpenStruct.new(label: "[#{community.community_id}] #{community.community_name}", value: edit_community_path(community.public_id))
      end

    # Since the value is the route, we have to rebuild that to select it
    selected_community = edit_community_path(@community.public_id) if @community.present?
    options_from_collection_for_select(communities, :value, :label, selected_community)
  end
end
All opinions represented herein are my own
- © 2024 itsthedevman
- build 3c15a1b