How do I replicate my console exercise in my view and controller?

I tried out some code in my console and I am having difficulty
translating it for my view and controller so that it gives me the same
My console:

        @contract = "900700", st_date:
        end_date: "2012-30-06")

        @code = "S-5463", status: "Active",
        description: "This and That")

        @codeline = => "80.00",
        :contract => @contract)

        => #<Codeline id: 91, contract_id: 64, code_id: 54, units_alloc:

Using pgadmin3 I check my codelines table and I get the same result

        id contract_id code_id units_alloc
        91 64 54 80.00

But if I try to run this through my contracts_controller and view I get:

        id contract_id code_id units_alloc
        91 64 54
        92 64 80.00

Here are my models:

  class Contract < AR::Base
    has_many :codelines
    has_many :codes, :through => :codelines

    accepts_nested_attributes_for :codes

    attr_accessible :codes_attributes,

  class Codeline < AR::Base
    belongs_to :contract
    belongs_to :code
    units_alloc ...... this is the attribute I would like to set

  class Code < AR::Base
    has_many :codelines
    has_many :contracts, :through => :codelines

The new/create action of my app/controllers/contracts_controller.rb

  def new
    @contract = => params[:units_alloc],
    :contract => @contract)

  def create
     @contract =[:contract])
       flash[:success] = "New Contract has been saved"
       redirect_to @contract
       @title = "You have some errors"
       render 'new'

the partial for my view in app/views/contracts/_fields.html.haml

    = f.fields_for :codes do |ff|
         = ff.label :name, "Code Name"
         = ff.text_field :code_name
    = f.fields_for :codelines do |ff|
        = ff.label :name, "Units Alloc"
        = ff.text_field :units_alloc

Please have a look to see if you can help me translate my console code
into the appropriate code for my contracts_controller?