How to validate a select_date in rails - ruby-on-rails

Beginners in rails here, I try to allow the users to my company website to enter their birthdate with a date_select.
Everything works fine until I enter an invalid date such as the 31 of february. It gives me an argumentError saying that the date is invalid.
I'd like to catch the error without adding a gem to my config, but it's blurry to me and everything I tried during the last two days did not work.
This is my user.rb file
validate :ensure_birth_date_valid, if: lambda { mentee? && born_on.present? }
def ensure_birth_date_valid
Date.parse(born_on)
rescue
error.add(:born_on, :invalid)
end
Here is the form
<% if registration_for?(:mentee) %>
<div class="lobbyForm-group">
<%= f.label :born_on, class: 'lobbyForm-label' %>
<%= f.date_select :born_on, { :start_year => Date.today.year - Application::MENTEE_AGE_RANGE_MIN, :end_year => Date.today.year - Application::MENTEE_AGE_RANGE_MAX, :order => [:day, :month, :year], :prompt => true}, {:class => 'lobbyForm-control w-auto'} %>
</div>
<% end %>
Here is the code that transform the date_select into a date
def user_params
if params[:user]['born_on(1i)'].present? && params[:user]['born_on(2i)'].present? && params[:user]['born_on(3i)'].present?
date = Date.new params[:user]['born_on(1i)'].to_i, params[:user]['born_on(2i)'].to_i, params[:user]['born_on(3i)'].to_i
params[:user][:born_on] = date
end
permitted_params = [:first_name, :last_name, :email, :password, :password_confirmation, :born_on, :marketing_communications_accepted]
params.require(:user).permit(*permitted_params)
params[:user].merge mentee: true
end
Here is the full stack trace error
/work/academos/academos-plateforme-web/app/controllers/lobby/mentee_registrations_controller.rb:36:in `new'
/work/academos/academos-plateforme-web/app/controllers/lobby/mentee_registrations_controller.rb:36:in `user_params'
/work/academos/academos-plateforme-web/app/controllers/lobby/registrations_controller.rb:25:in `create'
/work/academos/academos-plateforme-web/app/controllers/lobby/mentee_registrations_controller.rb:12:in `create'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/abstract_controller/base.rb:189:in `process_action'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_controller/metal/rendering.rb:10:in `process_action'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.1.11/lib/active_support/callbacks.rb:113:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.1.11/lib/active_support/callbacks.rb:113:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.1.11/lib/active_support/callbacks.rb:552:in `block (2 levels) in compile'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.1.11/lib/active_support/callbacks.rb:502:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.1.11/lib/active_support/callbacks.rb:502:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.1.11/lib/active_support/callbacks.rb:86:in `run_callbacks'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/abstract_controller/callbacks.rb:19:in `process_action'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_controller/metal/rescue.rb:29:in `process_action'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.1.11/lib/active_support/notifications.rb:159:in `block in instrument'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.1.11/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.1.11/lib/active_support/notifications.rb:159:in `instrument'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.1.11/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/abstract_controller/base.rb:136:in `process'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionview-4.1.11/lib/action_view/rendering.rb:30:in `process'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_controller/metal.rb:196:in `dispatch'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_controller/metal.rb:232:in `block in action'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/routing/route_set.rb:82:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/routing/route_set.rb:50:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/journey/router.rb:73:in `block in call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/journey/router.rb:59:in `each'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/journey/router.rb:59:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/routing/route_set.rb:692:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:164:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:164:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/bullet-4.8.0/lib/bullet/rack.rb:10:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/rack/error_collector.rb:50:in `traced_call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/rack/agent_hooks.rb:26:in `traced_call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/rack/browser_monitoring.rb:23:in `traced_call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/rack/developer_mode.rb:48:in `traced_call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/warden-1.2.3/lib/warden/manager.rb:35:in `block in call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `catch'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-1.5.4/lib/rack/etag.rb:23:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-1.5.4/lib/rack/conditionalget.rb:35:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-1.5.4/lib/rack/head.rb:11:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/remotipart-1.2.1/lib/remotipart/middleware.rb:27:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/middleware/flash.rb:254:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-1.5.4/lib/rack/session/abstract/id.rb:225:in `context'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-1.5.4/lib/rack/session/abstract/id.rb:220:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/middleware/cookies.rb:562:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.1.11/lib/active_record/query_cache.rb:36:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.1.11/lib/active_record/migration.rb:380:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.1.11/lib/active_support/callbacks.rb:82:in `run_callbacks'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/middleware/reloader.rb:73:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.1.11/lib/rails/rack/logger.rb:38:in `call_app'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.1.11/lib/rails/rack/logger.rb:22:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/middleware/request_id.rb:21:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-1.5.4/lib/rack/methodoverride.rb:21:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-1.5.4/lib/rack/runtime.rb:17:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.1.11/lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-1.5.4/lib/rack/lock.rb:17:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.1.11/lib/action_dispatch/middleware/static.rb:84:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-1.5.4/lib/rack/sendfile.rb:112:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sentry-raven-0.13.3/lib/raven/integrations/rack.rb:54:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.1.11/lib/rails/engine.rb:514:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.1.11/lib/rails/application.rb:144:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/newrelic_rpm-3.9.5.251/lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/puma-2.10.2/lib/puma/rack_patch.rb:13:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/puma-2.10.2/lib/puma/configuration.rb:74:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/puma-2.10.2/lib/puma/server.rb:492:in `handle_request'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/puma-2.10.2/lib/puma/server.rb:363:in `process_client'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/puma-2.10.2/lib/puma/server.rb:254:in `block in run'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/puma-2.10.2/lib/puma/thread_pool.rb:101:in `call'
/home/jb/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/puma-2.10.2/lib/puma/thread_pool.rb:101:in `block in spawn_thread'
Can anybody help?

Ok, I see. This is the problematic part:
date = Date.new params[:user]['born_on(1i)'].to_i, params[:user]['born_on(2i)'].to_i, params[:user]['born_on(3i)'].to_i
params[:user][:born_on] = date
You shouldn't be calling Date.new in the controller.
You can do something in the line of
date = "#{params[:user]['born_on(1i)'].to_i}-#{params[:user]['born_on(2i)'].to_i}-#{params[:user]['born_on(3i)'].to_i}"
params[:user][:born_on] = date
Now that you will have Date.parse('2016-02-31') and the errors can be added.

Related

ActionController known Format

I am having an issue with this code. It is for uploading an audio file. When I upload it I get an error saying this:
ActionController::UnknownFormat at /users/1/audios/dfdfdsdsf ============================================================ > ActionController::UnknownFormat app/controllers/audios_controller.rb, line 67 --------------------------------------------- ``` ruby 62 if #audio.errors.empty? && #audio.update_attributes(update_audio_params) 63 respond_to do |format| 64 format.html { redirect_to user_audios_path(#user) } 65 end 66 else > 67 respond_to do |format| 68 format.html { render :edit } 69 format.js { render json: { result: :failed, errors: #audio.errors } } 70 end 71 end 72 end ``` App backtrace ------------- - app/controllers/audios_controller.rb:67:in `update' Full backtrace -------------- - actionpack (4.2.3) lib/action_controller/metal/mime_responds.rb:217:in `respond_to' - app/controllers/audios_controller.rb:67:in `update' - actionpack (4.2.3) lib/action_controller/metal/implicit_render.rb:4:in `send_action' - actionpack (4.2.3) lib/abstract_controller/base.rb:198:in `process_action' - actionpack (4.2.3) lib/action_controller/metal/rendering.rb:10:in `process_action' - actionpack (4.2.3) lib/abstract_controller/callbacks.rb:20:in `block in process_action' - activesupport (4.2.3) lib/active_support/callbacks.rb:115:in `call' - activesupport (4.2.3) lib/active_support/callbacks.rb:553:in `block (2 levels) in compile' - activesupport (4.2.3) lib/active_support/callbacks.rb:503:in `call' - activesupport (4.2.3) lib/active_support/callbacks.rb:88:in `run_callbacks' - actionpack (4.2.3) lib/abstract_controller/callbacks.rb:19:in `process_action' - actionpack (4.2.3) lib/action_controller/metal/rescue.rb:29:in `process_action' - actionpack (4.2.3) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action' - activesupport (4.2.3) lib/active_support/notifications.rb:164:in `block in instrument' - activesupport (4.2.3) lib/active_support/notifications/instrumenter.rb:20:in `instrument' - activesupport (4.2.3) lib/active_support/notifications.rb:164:in `instrument' - actionpack (4.2.3) lib/action_controller/metal/instrumentation.rb:30:in `process_action' - actionpack (4.2.3) lib/action_controller/metal/params_wrapper.rb:250:in `process_action' - activerecord (4.2.3) lib/active_record/railties/controller_runtime.rb:18:in `process_action' - actionpack (4.2.3) lib/abstract_controller/base.rb:137:in `process' - actionview (4.2.3) lib/action_view/rendering.rb:30:in `process' - rack-mini-profiler (0.9.8) lib/mini_profiler/profiling_methods.rb:106:in `block in profile_method' - actionpack (4.2.3) lib/action_controller/metal.rb:196:in `dispatch' - actionpack (4.2.3) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch' - actionpack (4.2.3) lib/action_controller/metal.rb:237:in `block in action' - actionpack (4.2.3) lib/action_dispatch/routing/route_set.rb:76:in `dispatch' - actionpack (4.2.3) lib/action_dispatch/routing/route_set.rb:45:in `serve' - actionpack (4.2.3) lib/action_dispatch/journey/router.rb:43:in `block in serve' - actionpack (4.2.3) lib/action_dispatch/journey/router.rb:30:in `serve' - actionpack (4.2.3) lib/action_dispatch/routing/route_set.rb:821:in `call' - warden (1.2.3) lib/warden/manager.rb:35:in `block in call' - warden (1.2.3) lib/warden/manager.rb:34:in `call' - rack (1.6.4) lib/rack/etag.rb:24: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.3) lib/action_dispatch/middleware/params_parser.rb:27:in `call' - actionpack (4.2.3) 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.3) lib/action_dispatch/middleware/cookies.rb:560:in `call' - activerecord (4.2.3) lib/active_record/query_cache.rb:36:in `call' - activerecord (4.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call' - activerecord (4.2.3) lib/active_record/migration.rb:377:in `call' - actionpack (4.2.3) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' - activesupport (4.2.3) lib/active_support/callbacks.rb:84:in `run_callbacks' - actionpack (4.2.3) lib/action_dispatch/middleware/callbacks.rb:27:in `call' - actionpack (4.2.3) lib/action_dispatch/middleware/reloader.rb:73:in `call' - actionpack (4.2.3) lib/action_dispatch/middleware/remote_ip.rb:78:in `call' - better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call' - better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call' - better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call' - actionpack (4.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' - web-console (2.2.1) lib/web_console/middleware.rb:39:in `call' - actionpack (4.2.3) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' - railties (4.2.3) lib/rails/rack/logger.rb:38:in `call_app' - railties (4.2.3) lib/rails/rack/logger.rb:20:in `block in call' - activesupport (4.2.3) lib/active_support/tagged_logging.rb:68:in `block in tagged' - activesupport (4.2.3) lib/active_support/tagged_logging.rb:26:in `tagged' - activesupport (4.2.3) lib/active_support/tagged_logging.rb:68:in `tagged' - railties (4.2.3) lib/rails/rack/logger.rb:20:in `call' - actionpack (4.2.3) 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.3) 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.3) lib/action_dispatch/middleware/static.rb:116:in `call' - rack (1.6.4) lib/rack/sendfile.rb:113:in `call' - rack-mini-profiler (0.9.8) lib/mini_profiler/profiler.rb:282:in `call' - railties (4.2.3) lib/rails/engine.rb:518:in `call' - railties (4.2.3) lib/rails/application.rb:165:in `call' - rack (1.6.4) lib/rack/content_length.rb:15:in `call' - puma (2.12.2) lib/puma/server.rb:539:in `handle_request' - puma (2.12.2) lib/puma/server.rb:386:in `process_client' - puma (2.12.2) lib/puma/server.rb:269:in `block in run' - puma (2.12.2) lib/puma/thread_pool.rb:106:in `block in spawn_thread'
It might have to do with the respond_to block. Here is the code of that bellow:
def update
if params[:audio][:attachment].blank? && update_image_params.present?
#audio.update_audio_cover_picture update_image_params["photo"]
end
if #audio.errors.empty? && #audio.update_attributes(update_audio_params)
respond_to do |format|
format.html { redirect_to user_audios_path(#user) }
end
else
respond_to do |format|
format.html { render :edit }
format.js { render json: { result: :failed, errors: #audio.errors } }
end
end
end
This is a copy of the same code I use for my other project. It completely works on that app:
def update
if params[:book][:attachment].blank? && update_image_params.present?
#book.update_book_cover_picture update_image_params["photo"]
end
if #book.errors.empty? && #book.update_attributes(update_book_params)
respond_to do |format|
format.html { redirect_to user_books_path(#user) }
format.json { render json: { result: :success, url: user_books_url(#user) } }
end
else
respond_to do |format|
format.html { render :edit }
format.js { render json: { result: :failed, errors: #book.errors } }
end
end
end
From what your stack tells, it has something to do with the update method on your #audio. You are probably passing in weird parameters, or somehow filtering it incorrectly in your update_audio_params method.

Koala::Facebook::AuthenticationError - type: OAuthException, code: 2500, message

I am trying to setup a project. Everything has gone fine but this error keeps prompting up and nothing seems to help. Here is the log when i hit the url.
Koala::Facebook::AuthenticationError - type: OAuthException, code: 2500, message: An active access token must be used to query information about the current user. [HTTP 400]:
koala (2.2.0) lib/koala/api/graph_api.rb:515:in `block in graph_call'
koala (2.2.0) lib/koala/api.rb:80:in `api'
koala (2.2.0) lib/koala/api/graph_api.rb:513:in `graph_call'
koala (2.2.0) lib/koala/api/graph_api.rb:115:in `get_connection'
() home/yogesh/Desktop/jugojuice/jugojuice/app/controllers/pages_controller.rb:98:in `show'
() home/yogesh/Desktop/jugojuice/jugojuice/app/controllers/pages_controller.rb:64:in `home'
actionpack (4.2.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:308:in `block (2 levels) in halting'
() home/yogesh/.rvm/gems/ruby-2.2.3/bundler/gems/route_translator-f00b46885426/lib/route_translator/extensions/action_controller.rb:20:in `set_locale_from_url'
activesupport (4.2.0) lib/active_support/callbacks.rb:427:in `block in make_lambda'
activesupport (4.2.0) lib/active_support/callbacks.rb:307:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.0) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal.rb:236:in `block in action'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in `serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
xray-rails (0.1.16) lib/xray/middleware.rb:37:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.6.0) lib/rack/etag.rb:24:in `call'
rack (1.6.0) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.0) lib/rack/head.rb:13:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.0) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.0) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
activerecord (4.2.0) lib/active_record/migration.rb:378:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.0) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.0) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.0) lib/rack/lock.rb:17:in `call'
rack-livereload (0.3.15) lib/rack/livereload.rb:23:in `_call'
rack-livereload (0.3.15) lib/rack/livereload.rb:14:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.0) lib/rack/sendfile.rb:113:in `call'
railties (4.2.0) lib/rails/engine.rb:518:in `call'
railties (4.2.0) lib/rails/application.rb:164:in `call'
rack (1.6.0) lib/rack/lock.rb:17:in `call'
rack (1.6.0) lib/rack/content_length.rb:15:in `call'
rack (1.6.0) lib/rack/handler/webrick.rb:89:in `service'
() home/yogesh/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
() home/yogesh/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
() home/yogesh/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
logging (1.8.2) lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'
Started POST "/__better_errors/329b87011a8e5497/variables" for ::1 at 2015-11-18 16:48:21 +0530
My code in pages_controller.rb
class PagesController < ApplicationController
layout :determine_layout
before_filter :cms_setup, :only => [:show, :sitemap, :search]
before_filter :set_locale
helper_method :transformed_content
def parse_facebook_cookies
#facebook_cookies = Koala::Facebook::OAuth.new.get_user_info_from_cookie(cookies)
end
def sitemap
#page = Page.friendly.find("sitemap")
#subnav_pages = nil
end
def search
#page = Page.friendly.find("search")
#section = #page
#pages=Page.nested_set
#search = Sunspot.search([Cms::Page, Cms::Asset, Product, City, Location]) do
fulltext params[:terms] do
fields "title_#{I18n.locale}".to_sym, "content_#{I18n.locale}".to_sym, "description_#{I18n.locale}".to_sym, "address_#{I18n.locale}".to_sym
end
end
#results = #search.results
end
def cms_update
page = Page.find(params[:id])
region = Cms::Region.find(params[:region_id])
asset = Cms::Asset.find(params[:asset_id]) if params[:asset_id] && !params[:asset_id].blank?
# Update page
if asset
#asset.update_column(:content, params[:content])
if asset.content != params[:content]
asset.content = params[:content]
asset.save!
end
expire_fragment(["page_#{page.id}_region_#{region.id}_asset_#{asset.id}"])
else
asset = Cms::Asset.new(:content => params[:content], :name => "#{page.title} - #{region.name}")
asset.save
end
pra = Cms::PageRegionAsset.find_or_initialize_by(page_id: page.id, region_id: region.id, asset_id: asset.id) unless asset.nil?
unless params[:content].blank?
pra.save!
end
render text: ""
end
def home
response.headers.delete "X-Frame-Options"
#page = Page.root
get_site_pages
get_main_nav
get_subnav
#slides = Slide.visible.in_order
#newsletter_signup = NewsletterSignup.new
show
render "show"
end
def show
response.headers.delete "X-Frame-Options"
if #page.redirect_page_id.nil?
#get page template and regions
#template = #page.template
#regions = #template.regions
if #page.product_lines.any?
#product_line = #page.product_lines.first
end
if is_editing?
#page_content = HashWithIndifferentAccess[:regions => #regions.map { |r| {:placeholder => r.placeholder, :name => r.name, :id => r.id, :assets => r.serialized_assets_for(#page)}}.flatten]
else
#page_content = HashWithIndifferentAccess[:regions => #regions.map { |r|
{:placeholder => r.placeholder, :name => r.name, :id => r.id, :assets => r.serialized_assets_for(#page)}
}.flatten]
end
#cms_assets = #page.page_region_assets.order(position: :asc)
else
unless #page.redirect_page_id.nil?
#page = Page.find(#page.redirect_page_id)
redirect_to #page.menu_url and return
end
end
#instagram = Instagram.user_recent_media("2502342425320", {:count => 4})
#oauth = Koala::Facebook::OAuth.new("15239926112542342322478", "fc960a1a044492431aer35qafsd44a42c9c47990ef9b", "http://localhost:3000/")
#authtoken = #oauth.get_app_access_token
# generate authenticating URL
#graph = Koala::Facebook::API.new("1523992323611252478|1iBWrcRsYSBsISfsyUoNSmm_opxrI")
# #friends = #graph.get_connections("me", "friends")
# #profile = #graph.get_object("me")
#feed = #graph.get_connections("me", "feed")
end
def render_404
respond_to do |format|
format.html { render :file => "#{Rails.root}/public/404", :layout => false, :status => :not_found }
format.xml { head :not_found }
format.any { head :not_found }
end
end
private
def determine_layout
#page.template.file_name
end
def get_main_nav
#main_nav_items = Page.main_nav
end
def get_subnav
#subnav_pages = #page.subnav_pages
end
def get_site_pages
#site_pages = Page.nested_set.visible
end
def cms_setup
#render text: params.inspect and return
if params[:path].nil?
#page = Page.root
else
#page = Page.find_by_slug(params[:id]) if params[:id]
#page ||= Page.friendly.find(params[:path]) if params[:path]
#page ||= Page.root unless params[:path]
#page ||= Page.find_by(slug: params[:path].match(/[^\/]+$/)[0]) if params[:path]
#page ||= Page.find_by_slug("404")
if #page.nil?
#render text: params.inspect and return
render_404 and return
#page_not_found
redirect_to "/404" and return
end
end
#section = #page if #page.depth == 1
#section ||= #page.ancestors.select{|p| p.depth == 1}.first if #page.depth > 1
get_main_nav
get_subnav
end
def transformed_content(content)
frag = Nokogiri::HTML::fragment(content) #this gets us the regions content in a nodset
snippets = frag.css("div.cms-snippet")
dynamic_snippets = frag.xpath('descendant::div[#data-snippettype="dynamic"]')
dynamic_snippets.each do |ds|
object_class = ds.xpath("#data-objectclass")
object_id = ds.xpath("#data-objectid").first.value
snippet_partial = "/#{object_class.to_s.pluralize}/instance.html.haml"
ds.content = "" #zero out the content and replace it with a rendered partial
ds << (raw render :partial => snippet_partial, :locals => {:object_id => object_id}).to_s
end
frag
end
def page_params
params.require(:page).permit!
end
def page_not_found
raise ActionController::RoutingError.new('Not Found')
end
def set_locale
unless request.path.include?("/api")
#locale = params[:locale]
#locale ||= cookies[:locale]
#locale ||= I18n.default_locale
I18n.locale = #locale
if params[:locale].blank?
if cookies[:locale].blank?
redirect_to "/#{I18n.default_locale.to_s}#{request.path_info}" unless request.path.include?("/admin")
else
redirect_to "/#{cookies[:locale].to_s}#{request.path_info}" unless request.path.include?("/admin")
end
end
cookies[:locale] = I18n.locale
if request.path.include?("/admin")
I18n.locale = :en
end
end
end
end
I will be really thankful if someone tells me what is wrong here.
As #techdreams has commented, the error is the access token you're using, is invalid. Looking at your code seems you're getting the access token from a cookie. Just please keep in mind that an access token can become invalid if the user logs out of facebook or changes his/her password so you have always to implement a "refresh token" in your App, which basically is prompt the login dialog again to get a new token. If user has already approved your App this process will be transparent to him/her and they won't see the dialog again.

Why am I getting this TypeError? "no implicit conversion of Module into Integer"

I'm getting TypeError in CwIntegratorAccountsController#create. I'm calling a script (CwGetCompanyIntegrator.call) in the create method of the controller.
CwIntegratorAccountsController:
require 'apis/cw_get_company_integrator'
class CwIntegratorAccountsController < ApplicationController
skip_before_filter :require_company, :only => [:create,:new]
# GET /cw_integrator_accounts
# GET /cw_integrator_accounts.json
def create
unless CwIntegratorAccount.count >= 1
#cw_integrator_account = CwIntegratorAccount.new(params[:cw_integrator_account])
respond_to do |format|
if #cw_integrator_account.save
# Run the CW Integrator
CwGetCompanyIntegrator.call
format.html { redirect_to root_url, notice: 'cw_integrator success' }
#format.json { render json: #cw_integrator_account, status: :created, location: #cw_integrator_account }
else
format.html { render action: 'new' }
format.json { render json: #cw_integrator_account.errors, status: :unprocessable_entity }
end
end
end
end
end
It looks like it's failing when it starts the https request to the ConnectWise Server at this line: response = http.start {|h| h.request(request)}
CwGetCompanyIntegrator script:
#!/usr/bin/env ruby
require 'net/https'
require 'uri'
require 'nokogiri'
require 'apis/cw_apis'
class CwGetCompanyIntegrator
def self.call
cw_integrator_account = CwIntegratorAccount.first
cw_hostname = cw_integrator_account.cw_hostname
company_api_url = "https://#{cw_hostname}/v4_6_release/apis/2.0/CompanyApi.asmx"
uri = URI.parse(company_api_url)
request = Net::HTTP::Post.new(uri.path)
request.add_field('Content-Type', 'text/xml; charset=utf-8')
request.add_field('SOAPAction', 'http://connectwise.com/GetCompany')
request.body = CwApis.get_company_xml_request
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = http.start {|h| h.request(request)}
xml_doc = Nokogiri::XML(response.body).remove_namespaces!
company_name = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/CompanyName').text
company_street_addr = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/DefaultAddress/StreetLines/string')[0].text
begin
company_street_addr2 = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/DefaultAddress/StreetLines/string')[1].text
end
company_city = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/DefaultAddress/City').text
company_state = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/DefaultAddress/State').text
company_zip = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/DefaultAddress/Zip').text
company_country = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/DefaultAddress/Country').text
company_status = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/Status').text
company_phone = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/PhoneNumber').text
company_fax = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/FaxNumber').text
company_www = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/WebSite').text
CompanyInfosController.create!(cw_company_id: cw_integrator_account.cw_company_id, company_name: company_name,
company_street_addr: company_street_addr, company_street_addr2: company_street_addr2,
company_city: company_city, company_state: company_state, company_zip: company_zip,
company_country:company_country, company_status: company_status, company_phone: company_phone,
company_fax: company_fax, company_www: company_www)
end
end
This Class is called in the CwGetCompanyIntegrator script:
#!/usr/bin/env ruby
require 'builder'
class CwApis
def self.get_company_xml_request
cw_integrator_account = CwIntegratorAccount.first
integrator_company_id = cw_integrator_account.integrator_company_id
integrator_login_id = cw_integrator_account.integrator_login_id
integrator_password = cw_integrator_account.integrator_password
xml = Builder::XmlMarkup.new(:indent=>2)
xml.instruct!
xml.tag!('soap:Envelope',
:'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/',
:xmlns => 'http://connectwise.com'){
xml.tag!('soap:Body'){
xml.tag!('GetCompany'){
xml.tag!('credentials'){
xml.CompanyId(integrator_company_id)
xml.IntegratorLoginId(integrator_login_id)
xml.IntegratorPassword(integrator_password)
}
xml.id(cw_integrator_account.cw_company_id)
}
}
}
end
end
Full trace:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:893:in `initialize'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:893:in `new'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:893:in `connect'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:851:in `start'
lib/apis/cw_get_company_integrator.rb:21:in `call'
app/controllers/cw_integrator_accounts_controller.rb:54:in `block in create'
actionpack (3.2.14) lib/action_controller/metal/mime_responds.rb:270:in `call'
actionpack (3.2.14) lib/action_controller/metal/mime_responds.rb:270:in `retrieve_collector_from_mimes'
actionpack (3.2.14) lib/action_controller/metal/mime_responds.rb:194:in `respond_to'
app/controllers/cw_integrator_accounts_controller.rb:50:in `create'
actionpack (3.2.14) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.14) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.14) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.14) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.14) lib/active_support/callbacks.rb:447:in `_run__2237874046494148672__process_action__4163123032493016418__callbacks'
activesupport (3.2.14) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.14) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.14) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.14) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.14) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.14) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.14) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.14) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.14) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.14) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.14) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.14) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.14) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.14) lib/abstract_controller/rendering.rb:45:in `process'
rack-mini-profiler (0.9.2) lib/mini_profiler/profiling_methods.rb:108:in `block in profile_method'
actionpack (3.2.14) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.14) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.14) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.14) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.14) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.14) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.14) lib/action_dispatch/routing/route_set.rb:608:in `call'
rack-webconsole-pry (0.1.9) lib/rack/webconsole/assets.rb:26:in `call'
rack-webconsole-pry (0.1.9) lib/rack/webconsole.rb:79:in `call'
actionpack (3.2.14) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.5) lib/rack/etag.rb:23:in `call'
rack (1.4.5) lib/rack/conditionalget.rb:35:in `call'
actionpack (3.2.14) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.14) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.14) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.14) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.14) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.14) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.14) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.14) lib/active_support/callbacks.rb:405:in `_run__2942276951910103516__call__2669772965393719582__callbacks'
activesupport (3.2.14) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.14) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.14) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.14) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.14) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.14) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.14) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.14) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.14) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.14) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.14) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.14) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.14) 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.14) 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.14) lib/action_dispatch/middleware/static.rb:63:in `call'
rack-mini-profiler (0.9.2) lib/mini_profiler/profiler.rb:300:in `call'
railties (3.2.14) lib/rails/engine.rb:484:in `call'
railties (3.2.14) lib/rails/application.rb:231:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.14) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
This works in a plain ruby script, is it an environment thing?
Working Ruby Scripts:
CompanyApis class:
require 'builder'
class CompanyApis
def self.get_company
cw_company_id = 21920
integrator_company_id = 'COMPANY_ID'
integrator_login_id = 'INTERGRATOR_LOGIN'
integrator_password = 'INTERGRATOR_PW'
xml = Builder::XmlMarkup.new(:indent=>2)
xml.instruct!
xml.tag!('soap:Envelope',
:'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/',
:xmlns => 'http://connectwise.com'){
xml.tag!('soap:Body'){
xml.tag!('GetCompany'){
xml.tag!('credentials'){
xml.CompanyId(integrator_company_id)
xml.IntegratorLoginId(integrator_login_id)
xml.IntegratorPassword(integrator_password)
}
xml.id(cw_company_id)
}
}
}
end
end
CwIntegrator class:
require 'net/https'
require 'uri'
require 'nokogiri'
require './company_api'
class CwIntegrator
def self.call
cw_company_id = 21920
cw_hostname = 'cw.host.com'
companyapi_url = "https://#{cw_hostname}/v4_6_release/apis/2.0/CompanyApi.asmx"
uri = URI.parse(companyapi_url)
# Use for proxying to Kali
#proxy_addr = '172.16.1.149'
#proxy_port = 8080
request = Net::HTTP::Post.new(uri.path)
request.add_field('Content-Type', 'text/xml; charset=utf-8')
request.add_field('SOAPAction', 'http://connectwise.com/GetCompany')
request.body = CompanyApis.get_company
http = Net::HTTP.new(uri.host, uri.port)
# Use for proxying to Kali
#http = Net::HTTP.new(uri.host, uri.port, proxy_addr, proxy_port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = http.start {|h| h.request(request)}
company_info = []
xml_doc = Nokogiri::XML(response.body).remove_namespaces!
company_name = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/CompanyName').text
company_street_addr = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/DefaultAddress/StreetLines/string')[0].text
begin
company_street_addr2 = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/DefaultAddress/StreetLines/string')[1].text
end
company_city = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/DefaultAddress/City').text
company_state = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/DefaultAddress/State').text
company_zip = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/DefaultAddress/Zip').text
company_country = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/DefaultAddress/Country').text
company_status = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/Status').text
company_phone = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/PhoneNumber').text
company_fax = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/FaxNumber').text
company_www = xml_doc.xpath('//Envelope/Body/GetCompanyResponse/GetCompanyResult/WebSite').text
company_info += [company_name: company_name, cw_company_id: cw_company_id, company_name: company_name,
company_street_addr: company_street_addr, company_street_addr2: company_street_addr2,
company_city: company_city, company_state: company_state, company_zip: company_zip,
company_country:company_country,company_status: company_status, company_phone: company_phone,
company_fax: company_fax, company_www: company_www]
puts(company_info)
end
end
CwIntegrator.call
Rails is jealous and greedy to some methods like call etc. Probably simple renaming of the target method from call to neutral my_call would resolve the problem.
I bet there rails pretend to gain full power on call method, overriding it after your class is initialized.

Sending Devise emails in production

I am having problem sending emails in production. Everything works fine in development. Specifically, I just want the app to be able to send the generic email messages from the Devise Gem.
Here's the the code in production.rb
config.action_mailer.default_url_options = { :host => 'http://ballnow.herokuapp.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: ENV["GMAIL_DOMAIN"],
authentication: 'plain',
enable_starttls_auto: true,
user_name: ENV["GMAIL_USERNAME"],
password: ENV["GMAIL_PASSWORD"]
}
I feel like it is something very stupid, but for the past few hours, I can't seem to figure it out. Here is the log from paper trail:
vendor/bundle/ruby/2.1.0/gems/actionmailer-4.1.1/lib/action_mailer/base.rb:525:in `deliver_mail'
vendor/bundle/ruby/2.1.0/gems/mail-2.5.4/lib/mail/message.rb:232:in `deliver'
vendor/bundle/ruby/2.1.0/gems/devise-3.2.4/lib/devise/models/authenticatable.rb:173:in `send_devise_notification'
vendor/bundle/ruby/2.1.0/gems/devise-3.2.4/lib/devise/models/confirmable.rb:102:in `send_confirmation_instructions'
vendor/bundle/ruby/2.1.0/gems/devise-3.2.4/lib/devise/models/confirmable.rb:117:in `block in resend_confirmation_instructions'
vendor/bundle/ruby/2.1.0/gems/devise-3.2.4/lib/devise/models/confirmable.rb:211:in `pending_any_confirmation'
vendor/bundle/ruby/2.1.0/gems/devise-3.2.4/lib/devise/models/confirmable.rb:116:in `resend_confirmation_instructions'
vendor/bundle/ruby/2.1.0/gems/devise-3.2.4/lib/devise/models/confirmable.rb:265:in `send_confirmation_instructions'
vendor/bundle/ruby/2.1.0/gems/devise-3.2.4/app/controllers/devise/confirmations_controller.rb:9:in `create'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/abstract_controller/base.rb:189:in `process_action'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_controller/metal/rendering.rb:10:in `process_action'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:113:in `call'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:113:in `call'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:229:in `call'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:229:in `block in halting'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:229:in `call'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:229:in `block in halting'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `call'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `call'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `run_callbacks'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/abstract_controller/callbacks.rb:19:in `process_action'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_controller/metal/rescue.rb:29:in `process_action'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `block in instrument'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/notifications.rb:159:in `instrument'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.1/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/abstract_controller/base.rb:136:in `process'
vendor/bundle/ruby/2.1.0/gems/actionview-4.1.1/lib/action_view/rendering.rb:30:in `process'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_controller/metal.rb:195:in `dispatch'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_controller/metal.rb:231:in `block in action'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/routing/route_set.rb:80:in `call'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/routing/route_set.rb:48:in `call'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/routing/mapper.rb:45:in `call'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/journey/router.rb:71:in `block in call'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/journey/router.rb:59:in `each'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/journey/router.rb:59:in `call'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/routing/route_set.rb:676:in `call'
vendor/bundle/ruby/2.1.0/gems/newrelic_rpm-3.8.1.221/lib/new_relic/rack/error_collector.rb:55:in `call'
vendor/bundle/ruby/2.1.0/gems/newrelic_rpm-3.8.1.221/lib/new_relic/rack/agent_hooks.rb:32:in `call'
vendor/bundle/ruby/2.1.0/gems/newrelic_rpm-3.8.1.221/lib/new_relic/rack/browser_monitoring.rb:27:in `call'
vendor/bundle/ruby/2.1.0/gems/warden-1.2.3/lib/warden/manager.rb:35:in `block in call'
vendor/bundle/ruby/2.1.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `catch'
vendor/bundle/ruby/2.1.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `call'
vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/etag.rb:23:in `call'
vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/conditionalget.rb:35:in `call'
vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/flash.rb:254:in `call'
vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225:in `context'
vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:in `call'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/cookies.rb:560:in `call'
vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.1/lib/active_record/query_cache.rb:36:in `call'
vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:82:in `run_callbacks'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/rack/logger.rb:38:in `call_app'
vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/rack/logger.rb:20:in `block in call'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/tagged_logging.rb:68:in `block in tagged'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/tagged_logging.rb:26:in `tagged'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/tagged_logging.rb:68:in `tagged'
vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/rack/logger.rb:20:in `call'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/static.rb:64:in `call'
vendor/bundle/ruby/2.1.0/gems/heroku-deflater-0.5.3/lib/heroku-deflater/skip_binary.rb:19:in `call'
vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/deflater.rb:25:in `call'
vendor/bundle/ruby/2.1.0/gems/heroku-deflater-0.5.3/lib/heroku-deflater/serve_zipped_assets.rb:50:in `call'
vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call'
vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/engine.rb:514:in `call'
vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/application.rb:144:in `call'
vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:576:in `process_client'
vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:670:in `worker_loop'
vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:525:in `spawn_missing_workers'
vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:140:in `start'
vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `load'
vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `<main>'
Sent mail to wilson.lee86#gmail.com (148.7ms)
Completed 500 Internal Server Error in 1290ms
You should set domain (not URL) as default url options host. Just try to remove http://
config.action_mailer.default_url_options = { host: 'ballnow.herokuapp.com' }
Hope it helps.

Rails polymorphic association call model that doesn't exist

I've a problem with call model that doesn't exist. I have model CommandSet that is on polymorphic association with model RecordLevelSecurity that has securable field that can contains IbmiCommandSet or CommandSet. I've a just one model for IbmiCommandSet and CommandSet and it's of course CommandSet.So than I have tried find Role with RecordLevelPermissionthat is contains RecordLevelSecurity's id.Rails gives following error after my attempt Find Role.
def edit
#system_settings = ##system_settings
#role = Role.find(params[:id], :include => {:record_level_permissions => {:record_level_security => :securable}})
set_view_only
if !params[:page] && !params[:list]
show_role
elsif params[:list]
render_list_partial
else
render_edit_partial
end
end
NameError (uninitialized constant IbmiCommandSet):
org/jruby/RubyArray.java:1612:in `each'
org/jruby/RubyArray.java:1612:in `each'
org/jruby/RubyKernel.java:2105:in `send'
org/jruby/RubyArray.java:1612:in `each'
org/jruby/RubyHash.java:1170:in `each'
org/jruby/RubyHash.java:1170:in `each'
org/jruby/RubyArray.java:1612:in `each'
app/controllers/roles_controller.rb:56:in `edit'
org/jruby/RubyKernel.java:2093:in `send'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:220:in `call'

Resources