wiz561-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jul-10 16:53 UTC
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. :) 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! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
wiz561-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 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 ? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
wiz561-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jul-11 14:13 UTC
Re: Putting environment variables in DB
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 Rosenfeld <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 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 > ? > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---