using import CSV with params

Hi Guys,

I am using import CSV to import from a csv file to my database in my
rails app. I want to be able to be able to add a list of email
addresses from this file but also include the mailinglist_id which is
a param[:id] on my page in the database entry. So in effect adding a
csv of emails to any mailing list.

I am just a little unclear as to how I add the extra field when adding
the data to the database.... any help would be great!!

Database table "mailings" is as follows...

mailinglist_id, id, name, email_address

if I get this right, in this line:
Mailing.create!(row.to_hash)
you want to add the :malinglist_id from params[:id]

that should work:
Mailing.create!(row.to_hash.merge!({:malinglist_id => params[:id]}))

Hi denver,

denver wrote:

I am using import CSV to import from a csv file to my database
in my rails app. I want to be able to be able to add a list of email
addresses from this file but also include the mailinglist_id which is
a param[:id] on my page in the database entry. So in effect adding
a csv of emails to any mailing list.

I am just a little unclear as to how I add the extra field when adding
the data to the database.... any help would be great!!

The easiest way might be to add a hidden field to your form to pass the
controller the mailinglist_id. I've added a little code below (untested)
that might do the trick.

HTH,
Bill