表单没有在rails中响应

时间:2013-04-13 15:23:44

标签: ruby-on-rails ruby ruby-on-rails-3 rubygems ruby-on-rails-3.2

以下是我的代码。我的表格没有回应我的任何行为。我做错了什么。 我有用户填写账单/送货地址,提交后我指示他进行交易。这里我的表格没有响应,没有错误 我记录我看到以下错误

  Started GET "/orders/53/themes/js/jquery.lightbox-0.5.js" for 127.0.0.1 at 2013-04-13 08:19:03 -0700

     ActionController::RoutingError (No route matches [GET] "/orders/53/themes/js/jquery.lightbox-0.5.js"):
     actionpack (3.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
     actionpack (3.2.3) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
     railties (3.2.3) lib/rails/rack/logger.rb:26:in `call_app'
     railties (3.2.3) lib/rails/rack/logger.rb:16:in `call'
    actionpack (3.2.3) lib/action_dispatch/middleware/request_id.rb:22:in `call'
     rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
     rack (1.4.5) lib/rack/runtime.rb:17:in `call'
      activesupport (3.2.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
      rack (1.4.5) lib/rack/lock.rb:15:in `call'
      actionpack (3.2.3) lib/action_dispatch/middleware/static.rb:62:in `call'
      railties (3.2.3) lib/rails/engine.rb:479:in `call'
       railties (3.2.3) lib/rails/application.rb:220:in `call'
       rack (1.4.5) lib/rack/content_length.rb:14:in `call'
        railties (3.2.3) lib/rails/rack/log_tailer.rb:14:in `call'
      rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
       /Users//.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
       /Users/vpendyam/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
            /Users/vpendyam/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'


         Rendered /Users/***/.rvm/gems/ruby-1.9.2-p320@byagustore/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.8ms)


Transactions form
<%= form_for(@transaction) do |f| %>

<div class="span9">
    <h3> Place Order</h3>
    <div class="alert-error">
        <%= render "shared/error_messages", :target => @order %>
    </div>

 <div class="well">
 <div class="control-group"> <%= f.label :card_type %>
 <div class="controls">
<%= f.select :card_type, [["Visa", "visa"], ["MasterCard", "master"], ["Discover", "discover"], ["American Express", "american_express"]],:class=>"span3" %>
 </div>
 </div>

 <div class="control-group">
 <%= f.label :card_number %>
 <div class="controls">
  <input type="text" size="20" autocomplete="off" data-encrypted-name="number" />
  </div>
  </div>
  <div class="control-group">
  <%= f.label :cvv, "Card Verification Value (CVV)" %>
  <div class="controls">
   <input type="text" size="4" autocomplete="off" data-encrypted-name="cvv" />
  </div>
  </div>
  <div class="control-group">
  <%= f.label :card_expires_on %>
   <div class="controls">
          <input type="text" size="2" data-encrypted-name="month" /> / <input type="text" size="4" data-encrypted-name="year" />
   </div>
   </div>

 <%= f.submit "Place Order",:class=>"btn btn-success btn-large" %>

<%end %>
</div>
</div>  
<script type="text/javascript" src="https://js.braintreegateway.com/v1/braintree.js"></script>
<script type="text/javascript" src="../assets/javascript/Braintree.js"></script>

交易控制器

def create 
      @category_div = Category.get_category
      @order = Order.find(params[:order_id])
  @transaction = transaction.new(params[:transaction])

 @result = Braintree::Transaction.sale(:amount => @amount,
 :credit_card => {
  :number => @transaction[:credit_card],
  :cvv => @transaction[:cvv],
  :expiration_month => '11',
  :expiration_year => '2013'
},
:options => {
  :submit_for_settlement => true
})

if @result.success?
  render :action => "success"

else
  @amount = calculate_amount
  render :action => "error"
end

 end

交易模型

    class Transaction < ActiveRecord::Base
   attr_accessible :action, :amount, :authorization, :message, :order_id, :params, :success, 
   :response,:card_type,:cvv,:card_expires_on
   attr_accessor :card_number
  belongs_to :order
 serialize :params
  validates :card_number,:cvv,:card_expires_on, :presence => true
   end

路由

resources :users

  resources :orders do
   resources :transactions
  end
   resources :transactions
  resources :line_items


    resources :carts

   resources :products do
      resources :photos
    end

  resources :category , :only => [:index,:show]

   resources :payments, :only => :new
     match "/line_items/:id" => "line_items#update"
     match "carts/:id" => "carts#show"
     match "/orders/:order_id/transactions/new" => "transactions#new" ,:as => :transactions

0 个答案:

没有答案