2011-11-16 17 views
0

ここでの洞察は大歓迎です。レール内のform_forの内側からRails 3のデータベースから複数の選択値を選択する際に問題が発生する

は、私はこのように、データベースに複数の値を選択を挿入しています:

<div class="new-partner-form"> 
<%= form_for [:admin, matching_profile.partner, matching_profile], :html => {:id => "edit_profile", :multipart => true} do |f| %> 
<%= f.submit "Submit", :class => "hidden" %>  
    <div class="rounded-block quarter-wide radio-group"> 
    <h4>Exclude customers from source:</h4> 
    <%= f.select :source, User.select(:source).group(:source).order(:source).map {|u| [u.source,u.source]}, {:include_blank => false}, {:multiple => true} %> 
    <%= f.error_message_on :source %> 
    </div> 

私は、このようなデータベースから値を引くしようとしている:

def does_not_contain_source(matching_profiles) 
    Expression.select(matching_profiles, :source) do |keyword| 
    Rails.logger.info("Keyword is : " + keyword) 
    @customer_source_tokenizer ||= Tokenizer.new(User.select(:source).where("id = ?", self.owner_id).map {|u| u.source}[0]) #User.select("source").where("id = ?", self.owner_id).to_s) 
    @customer_source_tokenizer.divergent?(keyword) 
    end 
end 

が、この取得:

ExpressionErrors: Bad syntax: --- 
- "" 
- B 
- "" 

この値は、データベースにあるが、それは見るものですこのように私がアクセスすると、チョークするms。これを行う正しい方法は何ですか?

このように私に聞かせてください。

--- 
- "" 
- B 
- " 

DBに選択されているもの、私は保存することができ、より良い、より便利な方法がある:複数選択からのユーザの選択は、DBフィールドに、このように挿入されていますか?

答えて

0

これが助けになりました。 matching_profilesのモデル:

serialize :excluded_sources 
serialize :included_sources 
関連する問題