2

現時点では、通常の古い text_field を使用して Ransack を使用して検索に成功していますが、データベースにあるものの選択リストを含むオプション タグが必要です。

私の最初の質問は、オプション タグを適切に使用してリストをフィルタリングする方法です....

私の2番目の質問は、これらのオプションをデータベースにあるもので埋める方法です

ので、私は持っています

地区名 - サクラメント - サンディエゴ - 他の何か - 別の地区

私のテーブルが載っているページです (_table_discounts.html.haml)

%tbody
  - @property_application.each do |pa|
  %tr
    %td.align_left= pa.project.token
    %td.align_center= pa.project.district.name
    %td.align_center
      = pa.property.address
      %br
      = pa.property.city
      = pa.property.state
      = pa.property.zipcode
    %td.align_center= pa.created_at.strftime("%b %d, %Y")
  %td.align_center= pa.submitter.try(:full_name)
  %td.align_center= pa.discount_code

これが私のコントローラーです (discounts_controller.rb)

def show
  @search = PropertyApplication.search(params[:q])
  @property_application = @search.result
  discount_codes
end

def set_filter
  @search = PropertyApplication.search(params[:q])
  @property_application = @search.result(:distinct => true)
  @search.build_condition
  discount_codes
  respond_to do |format|
    format.html { render :show }
  end
end

これが私のフィルターです (_filter.html.haml)

= search_form_for @search, 
  :url => set_filter_manager_reports_discounts_path, 
  :html => {:method => :post} do |f|

= f.condition_fields do |c|
  .field
    = c.attribute_fields do |a|
      = a.attribute_select
    = c.predicate_select
    = c.value_fields do |v|
      = v.text_field :value
 .actions= f.submit "Search"

私は条件付きフィールドを持っていますが、それは私が望むものではありません......誰かが選択できるようにしたいだけです

地区 - サクラメント

その後、すべてにサクラメントが表示されます.....近づいているように感じますが、何かを理解していないように感じます........

どんなガイダンスでも大歓迎です

ありがとうございました

4

0 に答える 0