Re: Getting input''s value from a form

Jabbslad
Wed, 27 Feb 2008 17:47:47 -0000

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
>       )