Hi, In my application I use the NET::HTTP library to send a get request like that: The following method sends the request and return the response: res = Net::HTTP.get_response(www.somehost.com, /index.html) puts res.body I use this method in a model called Message, This model contains a number of attributes which are saved in the DB when the form is submitted. When the user submits the form, the get request is triggered and the data from the form is saved to the DB, but I need to additionally save the body of the resbonse I created a field in the database for saving the body of each request, called response , but I don''t know how to do that. How do I get the value of res.body to be saved in the response field with other form-submitted data? Thanks in advance :) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Any help? Is that too novice or too difficult !! :) On 11/03/2008, AN@S <anas.marrawi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hi, > > In my application I use the NET::HTTP library to send a get request like > that: > > The following method sends the request and return the response: > > res = Net::HTTP.get_response(www.somehost.com, /index.html) > > puts res.body > > I use this method in a model called Message, This model contains a number > of attributes which are saved in the DB when the form is submitted. When the > user submits the form, the get request is triggered and the data from the > form is saved to the DB, but I need to additionally save the body of the > resbonse I created a field in the database for saving the body of each > request, called response , but I don''t know how to do that. How do I get the > value of res.body to be saved in the response field with other > form-submitted data? > > Thanks in advance :) >-- Anas Marrawi Visit me at: www.anasonline.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 12 Mar 2008, at 11:13, AN@S wrote:> Any help? Is that too novice or too difficult !! :) >What''s wrong with my_model.body = res.body ? Fred> On 11/03/2008, AN@S <anas.marrawi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > Hi, > > In my application I use the NET::HTTP library to send a get request > like that: > > The following method sends the request and return the response: > > res = Net::HTTP.get_response(www.somehost.com, /index.html) > > puts res.body > > I use this method in a model called Message, This model contains a > number of attributes which are saved in the DB when the form is > submitted. When the user submits the form, the get request is > triggered and the data from the form is saved to the DB, but I need > to additionally save the body of the resbonse I created a field in > the database for saving the body of each request, called response , > but I don''t know how to do that. How do I get the value of res.body > to be saved in the response field with other form-submitted data? >> Thanks in advance :) > > > > -- > Anas Marrawi > Visit me at: www.anasonline.net > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Message.response = res.body " undefined method `response='' for #<Class:0x2b5890c267f8> " ''response'' is the database field where the response should be saved. On 12/03/2008, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On 12 Mar 2008, at 11:13, AN@S wrote: > > > Any help? Is that too novice or too difficult !! :) > > > > > What''s wrong with my_model.body = res.body ? > > Fred > > > On 11/03/2008, AN@S <anas.marrawi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi, > > > > In my application I use the NET::HTTP library to send a get request > > like that: > > > > The following method sends the request and return the response: > > > > res = Net::HTTP.get_response(www.somehost.com, /index.html) > > > > puts res.body > > > > I use this method in a model called Message, This model contains a > > number of attributes which are saved in the DB when the form is > > submitted. When the user submits the form, the get request is > > triggered and the data from the form is saved to the DB, but I need > > to additionally save the body of the resbonse I created a field in > > the database for saving the body of each request, called response , > > but I don''t know how to do that. How do I get the value of res.body > > to be saved in the response field with other form-submitted data? > > > > > > Thanks in advance :) > > > > > > > > -- > > Anas Marrawi > > Visit me at: www.anasonline.net > > > > > > > > >-- Anas Marrawi Visit me at: www.anasonline.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 13 Mar 2008, at 10:00, AN@S wrote:> Message.response = res.body > > " > undefined method `response='' for #<Class:0x2b5890c267f8> > " > > ''response'' is the database field where the response should be saved.You''re trying to set it on the class. How could that ever work? You need to be working with an instance of Message. Fred.> On 12/03/2008, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On 12 Mar 2008, at 11:13, AN@S wrote: > > > Any help? Is that too novice or too difficult !! :) > > > > > What''s wrong with my_model.body = res.body ? > > Fred > > > On 11/03/2008, AN@S <anas.marrawi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi, > > > > In my application I use the NET::HTTP library to send a get request > > like that: > > > > The following method sends the request and return the response: > > > > res = Net::HTTP.get_response(www.somehost.com, /index.html) > > > > puts res.body > > > > I use this method in a model called Message, This model contains a > > number of attributes which are saved in the DB when the form is > > submitted. When the user submits the form, the get request is > > triggered and the data from the form is saved to the DB, but I need > > to additionally save the body of the resbonse I created a field in > > the database for saving the body of each request, called response , > > but I don''t know how to do that. How do I get the value of res.body > > to be saved in the response field with other form-submitted data? > > > > > > Thanks in advance :) > > > > > > > > -- > > Anas Marrawi > > Visit me at: www.anasonline.net > > > > > > > > > > > -- > Anas Marrawi > Visit me at: www.anasonline.net > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---