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.
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!
[email protected] wrote:
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.
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!
why is the #new method called twice? it’s sufficient enough to call it
once with the params[:response] hash
?
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.
Mike
On Jul 11, 2:42 am, Shai R. [email protected]