Skip to content

Instantly share code, notes, and snippets.

@gabeodess
Created February 16, 2016 20:36
Show Gist options
  • Save gabeodess/41ea620d335fabd0a3d4 to your computer and use it in GitHub Desktop.
Save gabeodess/41ea620d335fabd0a3d4 to your computer and use it in GitHub Desktop.
# @order.to_slack_json
{
:message => "this is a test"
}
TypeError in Slack::OrdersController#create
no implicit conversion of Array into String
Extracted source (around line #67):
65
66
67
68
69
70
body.each do |part|
parts << part
(digest ||= Digest::MD5.new) << part unless part.empty?
end
[digest && digest.hexdigest, parts]
Rails.root: /Users/gabeodess/Sites/slizza
Application Trace | Framework Trace | Full Trace
rack (1.6.4) lib/rack/etag.rb:67:in `<<'
rack (1.6.4) lib/rack/etag.rb:67:in `block in digest_body'
actionpack (4.2.5.1) lib/action_dispatch/http/response.rb:97:in `each'
actionpack (4.2.5.1) lib/action_dispatch/http/response.rb:97:in `each'
actionpack (4.2.5.1) lib/action_dispatch/http/response.rb:52:in `each'
actionpack (4.2.5.1) lib/action_dispatch/http/response.rb:361:in `each'
rack (1.6.4) lib/rack/etag.rb:65:in `digest_body'
rack (1.6.4) lib/rack/etag.rb:28:in `call'
rack (1.6.4) lib/rack/conditionalget.rb:38:in `call'
rack (1.6.4) lib/rack/head.rb:13:in `call'
actionpack (4.2.5.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.5.1) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.5.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.5.1) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.5.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
activerecord (4.2.5.1) lib/active_record/migration.rb:377:in `call'
actionpack (4.2.5.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.5.1) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
activesupport (4.2.5.1) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
activesupport (4.2.5.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.5.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.5.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.5.1) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.5.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `catch'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
actionpack (4.2.5.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.5.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.5.1) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.5.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.5.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.5.1) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.5.1) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.5.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.5.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
actionpack (4.2.5.1) lib/action_dispatch/middleware/static.rb:116:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
railties (4.2.5.1) lib/rails/engine.rb:518:in `call'
railties (4.2.5.1) lib/rails/application.rb:165:in `call'
puma (2.16.0) lib/puma/commonlogger.rb:31:in `call'
puma (2.16.0) lib/puma/configuration.rb:81:in `call'
puma (2.16.0) lib/puma/server.rb:557:in `handle_request'
puma (2.16.0) lib/puma/server.rb:404:in `process_client'
puma (2.16.0) lib/puma/server.rb:270:in `block in run'
puma (2.16.0) lib/puma/thread_pool.rb:106:in `call'
puma (2.16.0) lib/puma/thread_pool.rb:106:in `block in spawn_thread'
class Slack::OrdersController < ApplicationController
before_action :authenticate_slack!
skip_before_action :verify_authenticity_token
def create
end
private
def authenticate_slack!
raise ActionController::InvalidAuthenticityToken unless params[:token] == ENV['SLACK_VERIFICATION_TOKEN']
end
end
Rails.application.routes.draw do
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
root to: "home#index"
authenticate :user do
resource :account, :only => [:edit, :update, :show]
end
namespace :slack do
resources :orders, :only => [:create], :defaults => {:format => :json}
end
end
@gabeodess
Copy link
Author

The error is caused by not calling to_json on the hash. If you simply call to_json, the error goes away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment