I am following a new tutorial just added to the upcoming book, Advanced Rails Recipes. The recipe is, "Process Recurring Credit Card Payments". The tutorial is great and I recommend picking up the PDF book. Simply put, there is a card server, and a then your main application which is used to pass credit card numbers to the server. The problem I am having, is how do I get the parameters from the form into the controller without storing them in the model? It would be easy if I was storing the credit card number and expiration date in the user model, but I am not for security, so I cannot call @user.credit_card number. I guess I need something like page["input_credit_card].value? if @user.save self.current_user = @user cc = CreditCard.create(:first_name => @user.first_name, :last_name => @user.last_name, :number => #pick up from the form, :month => #pick up from the form, :year => #pick up from the form, :brand => #pickup from the form ) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
If you just want a CreditCard instance but do not want to persist it to the database you can use:- CreditCard.new(:first_name => @user.first_name, :last_name => @user.last_name, :number => #pick up from the form, :month => #pick up from the form, :year => #pick up from the form, :brand => #pickup from the form ) Is that what you are asking or do you want to know how to pull the values out of the params hash? Jabbslad On Feb 27, 5:09 pm, Keaja <jasonmw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am following a new tutorial just added to the upcoming book, > Advanced Rails Recipes. The recipe is, "Process Recurring Credit Card > Payments". The tutorial is great and I recommend picking up the PDF > book. > > Simply put, there is a card server, and a then your main application > which is used to pass credit card numbers to the server. > > The problem I am having, is how do I get the parameters from the form > into the controller without storing them in the model? It would be > easy if I was storing the credit card number and expiration date in > the user model, but I am not for security, so I cannot call > @user.credit_card number. I guess I need something like > page["input_credit_card].value? > > if @user.save > self.current_user = @user > cc = CreditCard.create(:first_name => @user.first_name, > :last_name => @user.last_name, > :number => #pick up from the form, > :month => #pick up from the form, > :year => #pick up from the form, > :brand => #pickup from the form > )--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
If I could get the values without persist to the database, that would be perfect. how can I do that? On Feb 27, 2008, at 9:47 AM, Jabbslad wrote:> > If you just want a CreditCard instance but do not want to persist it > to the database you can use:- > > CreditCard.new(:first_name => @user.first_name, > :last_name => @user.last_name, > :number => #pick up from the form, > :month => #pick up from the form, > :year => #pick up from the form, > :brand => #pickup from the form ) > > Is that what you are asking or do you want to know how to pull the > values out of the params hash? > > Jabbslad > > On Feb 27, 5:09 pm, Keaja <jasonmw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> I am following a new tutorial just added to the upcoming book, >> Advanced Rails Recipes. The recipe is, "Process Recurring Credit Card >> Payments". The tutorial is great and I recommend picking up the PDF >> book. >> >> Simply put, there is a card server, and a then your main application >> which is used to pass credit card numbers to the server. >> >> The problem I am having, is how do I get the parameters from the form >> into the controller without storing them in the model? It would be >> easy if I was storing the credit card number and expiration date in >> the user model, but I am not for security, so I cannot call >> @user.credit_card number. I guess I need something like >> page["input_credit_card].value? >> >> if @user.save >> self.current_user = @user >> cc = CreditCard.create(:first_name => @user.first_name, >> :last_name => @user.last_name, >> :number => #pick up from the form, >> :month => #pick up from the form, >> :year => #pick up from the form, >> :brand => #pickup from the form >> ) > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You can just use the id of the tag to retrieve the value from the params hash, e.g. Assuming you have something like this in your view:- <%= text_field_tag ''number'' %> You should be able to access it in your controller using:- :number => params[''number''] Is that what you were after? Jabbslad On Feb 27, 5:52 pm, "Jason M. Winn" <jasonmw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If I could get the values without persist to the database, that would > be perfect. how can I do that? > > On Feb 27, 2008, at 9:47 AM, Jabbslad wrote: > > > > > If you just want a CreditCard instance but do not want to persist it > > to the database you can use:- > > > CreditCard.new(:first_name => @user.first_name, > > :last_name => @user.last_name, > > :number => #pick up from the form, > > :month => #pick up from the form, > > :year => #pick up from the form, > > :brand => #pickup from the form ) > > > Is that what you are asking or do you want to know how to pull the > > values out of the params hash? > > > Jabbslad > > > On Feb 27, 5:09 pm, Keaja <jasonmw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> I am following a new tutorial just added to the upcoming book, > >> Advanced Rails Recipes. The recipe is, "Process Recurring Credit Card > >> Payments". The tutorial is great and I recommend picking up the PDF > >> book. > > >> Simply put, there is a card server, and a then your main application > >> which is used to pass credit card numbers to the server. > > >> The problem I am having, is how do I get the parameters from the form > >> into the controller without storing them in the model? It would be > >> easy if I was storing the credit card number and expiration date in > >> the user model, but I am not for security, so I cannot call > >> @user.credit_card number. I guess I need something like > >> page["input_credit_card].value? > > >> if @user.save > >> self.current_user = @user > >> cc = CreditCard.create(:first_name => @user.first_name, > >> :last_name => @user.last_name, > >> :number => #pick up from the form, > >> :month => #pick up from the form, > >> :year => #pick up from the form, > >> :brand => #pickup from the form > >> )--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
thanks Jabbslad, I forgot about just using text_field_tag On Feb 27, 2008, at 10:20 AM, Jabbslad wrote:> > You can just use the id of the tag to retrieve the value from the > params hash, e.g. > > Assuming you have something like this in your view:- > > <%= text_field_tag ''number'' %> > > You should be able to access it in your controller using:- > > :number => params[''number''] > > Is that what you were after? > > Jabbslad > > On Feb 27, 5:52 pm, "Jason M. Winn" <jasonmw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> If I could get the values without persist to the database, that would >> be perfect. how can I do that? >> >> On Feb 27, 2008, at 9:47 AM, Jabbslad wrote: >> >> >> >>> If you just want a CreditCard instance but do not want to persist it >>> to the database you can use:- >> >>> CreditCard.new(:first_name => @user.first_name, >>> :last_name => @user.last_name, >>> :number => #pick up from the form, >>> :month => #pick up from the form, >>> :year => #pick up from the form, >>> :brand => #pickup from the form ) >> >>> Is that what you are asking or do you want to know how to pull the >>> values out of the params hash? >> >>> Jabbslad >> >>> On Feb 27, 5:09 pm, Keaja <jasonmw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> I am following a new tutorial just added to the upcoming book, >>>> Advanced Rails Recipes. The recipe is, "Process Recurring Credit >>>> Card >>>> Payments". The tutorial is great and I recommend picking up the PDF >>>> book. >> >>>> Simply put, there is a card server, and a then your main >>>> application >>>> which is used to pass credit card numbers to the server. >> >>>> The problem I am having, is how do I get the parameters from the >>>> form >>>> into the controller without storing them in the model? It >>>> would be >>>> easy if I was storing the credit card number and expiration date in >>>> the user model, but I am not for security, so I cannot call >>>> @user.credit_card number. I guess I need something like >>>> page["input_credit_card].value? >> >>>> if @user.save >>>> self.current_user = @user >>>> cc = CreditCard.create(:first_name => @user.first_name, >>>> :last_name => @user.last_name, >>>> :number => #pick up from the form, >>>> :month => #pick up from the form, >>>> :year => #pick up from the form, >>>> :brand => #pickup from the form >>>> ) > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---