mongodb - Pass an array as parameter in ruby -


i'm trying diffusion (where send email lot of users). in model (with mongodb)

key :email, array   

in controller:

@users = params[:user] @emails = array.new @users.each |user|   @emails << user.find_by_username(user).email end 

so in link pass argument array:

<%= link_to "create diffusion", mailer_path(:user => user.all)%> 

in form:

<%= f.input :email, :as => :hidden, :input_html => { :value => @emails } %> 

the problem in mailer:

@message.email.each |email|   mail(:to => email, :subject => @message.subject) end 

the problem @message not array, string. loop once-loop. i've tried @message.email.split(",") doesn't work. think great if @message array (how should be)

someone can me? in advance

well, if you're naming somehow reflecting objects dealing with, maybe should try:

@emails.each |mail|   mail(:to => mail, :subject => @message.subject, ...) end 

and why not:

user.all.each |user|   mail(:to => user, :subject => @message.subject, ...) end 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -