Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 6.04 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. development.rb
  2.  
  3. Demo::Application.configure do
  4.   config.cache_classes = false
  5.   config.whiny_nils = true
  6.   config.consider_all_requests_local       = true
  7.   config.action_view.debug_rjs             = true
  8.   config.action_controller.perform_caching = true
  9.   config.action_mailer.raise_delivery_errors = true
  10.   config.action_mailer.delivery_method = :smtp
  11.   config.action_mailer.smtp_settings = {
  12.     # private
  13.   }
  14.   config.active_support.deprecation = :log
  15.   config.action_dispatch.best_standards_support = :builtin
  16.   config.session_store :active_record_store
  17.   config.action_mailer.default_url_options = { :host => "localhost:3000" }
  18. end
  19.  
  20. production.rb
  21.  
  22. Demo::Application.configure do
  23.   config.cache_classes = true
  24.   config.consider_all_requests_local       = false
  25.   config.action_controller.perform_caching = true
  26.   config.action_dispatch.x_sendfile_header = "X-Sendfile"
  27.   config.cache_store = :mem_cache_store, "localhost"
  28.   config.serve_static_assets = false
  29.   config.action_mailer.smtp_settings = {
  30.     # private  
  31.   }
  32.   config.action_mailer.default_url_options = { # private }
  33.   config.i18n.fallbacks = true
  34.   config.active_support.deprecation = :notify
  35. end
  36.  
  37. routes.rb partial:
  38.  
  39.   namespace 'accounting' do
  40.     resource :requisitions, :only => [:show] do
  41.       collection do
  42.         get 'filter'
  43.       end
  44.     end
  45.     resource :purchase_orders, :only => [:show]
  46.     resource :accounts_payable, :only => [:show]
  47.     resource :payment_requests, :only => [:show, :update]
  48.     resource :general_ledger, :only => [:show]
  49.     resource :permissions, :only => [:update]
  50.  
  51.     resources :payment_objects do
  52.       collection do
  53.         get 'filter'
  54.         post 'permissions'
  55.       end
  56.       member do
  57.         match 'approve'
  58.         match 'decline'
  59.       end
  60.       resources :items do
  61.         member do
  62.           get 'receive' => 'items#received_form'
  63.           post 'receive' => 'items#process_received_form'
  64.         end
  65.         resources :receiving_records, :only => [:create, :new]
  66.       end
  67.       resources :files
  68.       resources :comments do
  69.         collection do
  70.           post 'process' => 'comments#create'
  71.         end
  72.       end
  73.       resource :payment_schedule, :only => :show
  74.     end
  75.   end
  76.  
  77. app/controllers/comments_controller.rb:
  78.  
  79. class CommentsController < ApplicationController
  80.   before_filter :load_resource, :except => :spellchecker
  81.   before_filter :comment_owner_check, :only => [:edit, :update]
  82.  
  83.   # GET /instructions/:instruction_id/comments
  84.   # GET /requisitions/:requisition_id/comments
  85.   #
  86.   # Loads the content tab for Comment's Instruction.
  87.   def index
  88.     if @resource.class == Instruction
  89.       @create_url = comments_path(:instruction_id => @resource)
  90.       @discard_url = discard_draft_path(:instruction_id => @resource.id, :user_id => current_user.id)
  91.       @draft = current_user.draft.where(:instruction_id => @resource.id).last
  92.     elsif @resource.class == PaymentObject
  93.       @create_url = accounting_payment_object_comments_path(@resource)
  94.       @draft = current_user.draft.where(:payment_object_id => @resource.id).last
  95.     end
  96.  
  97.     @comment = @resource.comment.new
  98.     @comments = @resource.comment
  99.  
  100.     if @draft
  101.       @comment.content = @draft.content
  102.     end
  103.  
  104.     if request.xhr?
  105.       render :layout => false
  106.     end
  107.   end
  108. end
  109.  
  110. error:
  111.  
  112. from production:
  113.  
  114.  
  115. Started GET "/accounting/payment_objects/205/comments?_=1311567558808" for 218.103.118.132 at Mon Jul 25 12:19:23 +0800 2011
  116.  
  117. ActionController::RoutingError (uninitialized constant Accounting::CommentsController):
  118.  
  119.  
  120.  
  121. from development (same request):
  122.  
  123. Started GET "/accounting/payment_objects/206/comments?_=1311582674088" for 127.0.0.1 at 2011-07-25 16:31:14 +0800
  124.   Processing by CommentsController#index as
  125.   Parameters: {"_"=>"1311582674088", "payment_object_id"=>"206"}
  126.   User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY name ASC LIMIT 1
  127.   SQL (0.2ms)  SELECT COUNT(*) FROM `companies` WHERE `companies`.`id` = 1
  128.   Company Load (0.2ms)  SELECT `companies`.* FROM `companies` WHERE `companies`.`id` = 1 ORDER BY name ASC LIMIT 1
  129.   Permission Load (0.5ms)  SELECT `permissions`.* FROM `permissions` WHERE `permissions`.`subject_id` = 1 AND (`permissions`.user_id = 1)
  130.   PaymentObject Load (0.5ms)  SELECT `payment_objects`.* FROM `payment_objects` WHERE `payment_objects`.`id` = 206 AND (`payment_objects`.company_id = 1) ORDER BY id DESC LIMIT 1
  131.   Draft Load (0.3ms)  SELECT `drafts`.* FROM `drafts` WHERE `drafts`.`payment_object_id` = 206 AND (`drafts`.user_id = 1) ORDER BY drafts.id DESC LIMIT 1
  132.   Comment Load (0.5ms)  SELECT `comments`.* FROM `comments` WHERE (`comments`.payment_object_id = 206)
  133. Rendered comments/index.html.erb (4.3ms)
  134. Completed 200 OK in 562ms (Views: 7.0ms | ActiveRecord: 3.2ms)
  135.  
  136.  
  137. 1.8.7 development:
  138.  
  139. [2011-07-25 16:37:29] INFO  WEBrick 1.3.1
  140. [2011-07-25 16:37:29] INFO  ruby 1.8.7 (2010-04-19) [i686-darwin10.4.0]
  141. [2011-07-25 16:37:29] INFO  WEBrick::HTTPServer#start: pid=14738 port=3000
  142.  
  143.  
  144. Started GET "/accounting/payment_objects/206/items?_=1311583059577" for 127.0.0.1 at Mon Jul 25 16:37:39 +0800 2011
  145.   Processing by Accounting::ItemsController#index as
  146.   Parameters: {"payment_object_id"=>"206", "_"=>"1311583059577"}
  147.   User Load (0.3ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY name ASC LIMIT 1
  148.   SQL (0.3ms)  SELECT COUNT(*) FROM `companies` WHERE `companies`.`id` = 1
  149.   Company Load (0.7ms)  SELECT `companies`.* FROM `companies` WHERE `companies`.`id` = 1 ORDER BY name ASC LIMIT 1
  150.   Permission Load (0.4ms)  SELECT `permissions`.* FROM `permissions` WHERE `permissions`.`subject_id` = 1 AND (`permissions`.user_id = 1)
  151.   PaymentObject Load (0.3ms)  SELECT `payment_objects`.* FROM `payment_objects` WHERE `payment_objects`.`id` = 206 AND (`payment_objects`.company_id = 1) ORDER BY id DESC LIMIT 1
  152.   CACHE (0.0ms)  SELECT `companies`.* FROM `companies` WHERE `companies`.`id` = 1 ORDER BY name ASC LIMIT 1
  153.   PaymentObjectItem Load (0.7ms)  SELECT `payment_object_items`.* FROM `payment_object_items` WHERE (`payment_object_items`.payment_object_id = 206) ORDER BY item ASC
  154. Rendered accounting/items/index.html.erb (38.3ms)
  155. Completed 200 OK in 303ms (Views: 64.8ms | ActiveRecord: 202.1ms)