problems selecting a mutliple select value from database in Rails
Posted
by
Ramy
on Stack Overflow
See other posts from Stack Overflow
or by Ramy
Published on 2011-11-16T01:37:57Z
Indexed on
2011/11/16
1:50 UTC
Read the original article
Hit count: 266
From inside of a form_for in rails, I'm inserting multiple select values into the database, like this:
<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>
I'm then trying to pull the value from the database like this:
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
but getting this:
ExpressionErrors: Bad syntax: ---
- ""
- B
- ""
this is what the value is in the database but it seems to choke when i access it this way. What's the right way to do this?
© Stack Overflow or respective owner