質問

ActiveScfordリストページの私の通常の検索は機能していません。

フィールドIDを持つListLocationsテーブルを持っています。 list_id | wiki_location_id。 私は以下のモデル関係を持っています

       class List < ActiveRecord::Base
         validates_presence_of :name
         has_many :list_locations, :dependent => :destroy
       end


       class WikiLocation < ActiveRecord::Base
         has_many :list_locations, :dependent => :destroy
       end

       class ListLocation < ActiveRecord::Base
         belongs_to :list
         belongs_to :wiki_location

         def wiki_location_title
           WikiLocation.find(wiki_location_id).title if wiki_location_id
         end

         def wiki_location_title= (title)
           wiki_location = WikiLocation.find_by_title(title)
           self.wiki_location_id = wiki_location.id if wiki_location
         end
       end
.

これらのための私のコントローラーは

      class Admin::ListsController < Admin::AdminController
        active_scaffold :list do |conf|
          conf.columns = [:name, :list_order, :enabled]
          conf.columns[:enabled].form_ui = :checkbox 
          conf.columns[:enabled].inplace_edit = true
          list.sorting = {:list_order => 'asc'}
        end
      end


      class Admin::WikiLocationsController < Admin::AdminController
        active_scaffold :wiki_location do |conf|
          conf.columns = [:title, :street]
          list.per_page = 10
        end
      end 


     class Admin::ListLocationsController < Admin::AdminController  
       active_scaffold :list_location do |conf|
         conf.columns = [:list, :wiki_location]
         conf.columns[:list].form_ui = :select
         conf.search.columns << :list
       end
     end
.

LIST_LOCATIONSのwiki_locationフィールドのタイプ(Sayt)機能を検索しましたテーブル

私の景色はのように見えます

画像の記述ここで

ENTER IMENT Descriptionこちら

下記のリンク ACTIVAFFORDオートコンプリート

今私の問題は、アクティブな足場の私のリストページで通常検索を使っていたときのものです私は結果を得ていません

私のコンソールから得たクエリは

 SELECT `list_locations`.`id` AS t0_r0, `list_locations`.`list_id` AS t0_r1, 
 `list_locations`.`wiki_location_id` AS t0_r2, `list_locations`.`created_at` AS t0_r3,
 `list_locations`.`updated_at` AS t0_r4, `lists`.`id` AS t1_r0, `lists`.`name` AS t1_r1,
 `lists`.`list_order` AS t1_r2, `lists`.`enabled` AS t1_r3, `lists`.`created_at` AS 
  t1_r4, `lists`.`updated_at` AS t1_r5 FROM `list_locations` LEFT OUTER JOIN `lists` ON 
 `lists`.`id` = `list_locations`.`list_id` WHERE ((((`lists`.`id` LIKE '%museum%'))))
  ORDER BY `list_locations`.`id` ASC LIMIT 15 OFFSET 0
.

list.name の代わりにlists.idフィールドを検索するように見えます。

なぜこれが好きなのですか。どのようにして検索LIST.NAMEを作成できますか。私はまたWiki_locations.title列を検索する必要があります。これをどのようにして行うことができます。助けてください。

役に立ちましたか?

解決

Try to set:

conf.columns[:list].search_sql = 'list.name'
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top