Putting environment variables in DB

Hi!

I have another small question. I have an environment variable set in environment.rb. The line looks like...

ENV['username'] = 'mike'

What I would like to do is store 'mike' in the database in my 'login' column. In the controller, if I add this...

    @response = Response.new     @response = Response.new(params[:response])     @response.login = ENV['username']     @response.save

It will add one record that's the username and all the other columns blank. Then, it'll add another record with all the data. Essentially, it's adding two records. I used an example on this forum and it obviously didn't work very well. :slight_smile:

I was wondering if anybody had an idea of why I'm getting two records....and if there is a better way to do this.

Thanks!

Beats me. I tried to take out the first one (@response = Response.new), but then it didn't work and popped up with an error message.

What I've done instead was just place a hidden field in my view and have it record the username. I found a message in this group saying how you shouldn't do this and how you should use the method that I used. But, unfortunately, it doesn't work for me, and I can't find the thread that explained what it was doing now. :frowning:

Mike