Error passing time in a form when using CanCanCan - ruby-on-rails

I am using the gem 'bootstrap3-datetimepicker-rails', '~> 4.17' so that the user can select a date and time, which is passed to my controller and included in the model's attributes. However, when I add load_and_authorize_resource to the controller (using cancancan), I get the following error.
argument out of range
The error is happening because it is passing the date January 27, 2015, but the date and month numbers are switched, and it doesn't like getting a date with month=27, hence the out of range error. However, this error is not happening in my controller, and the whole process works fine when I remove load_and_authorize_resource from the controller.
How can I get this working (avoiding the error) while still authorizing the controller with cancancan?
I am using Rails 4.1.4 and Ruby 2.0.0. Any guidance would be much appreciated, thanks!
Edit: Adding code.
damages/new.html.erb
<%= simple_form_for([#car, #damage], html: {class: 'create-damage-form'}) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<span class='input-group date damage-datepicker'>
<%= f.text_field :date_of_damage, class: "form-control" %>
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</span>
</br>
<%= f.text_area :description, class: 'form-control form-solo-field', placeholder: 'Enter a description of the damage...' %>
</div>
<div class="form-actions">
</br>
<%= f.submit "Submit", class: "btn btn-primary btn-md" %>
</div>
<% end %>
damages_controller.rb
def create
if !params[:damage][:date_of_damage].nil?
date_of_damage = params[:damage][:date_of_damage]
else
redirect_to :back, alert: 'Enter the date of damage.'
return
end
begin
# auth_time = DateTime.strptime(auth_time, "%m-%d-%Y %H:%M%S")
date_of_damage = DateTime.strptime(date_of_damage,'%m/%d/%Y')
rescue ArgumentError => e
redirect_to :back, alert: 'Enter a valid date.'
return
end
#car = Car.find(params[:car_id])
damage_params_with_date = damage_params
damage_params_with_date[:date_of_damage] = date_of_damage
#damage = #car.damages.build(damage_params_with_date)
respond_to do |format|
if #damage.save
format.html { redirect_to #car, notice: 'Damage record was successfully added.' }
format.json { render :show, status: :created, location: #car }
else
format.html { redirect_to :back, alert: 'Damage record was not added.' }
format.json { render json: #damage.errors, status: :unprocessable_entity }
end
end
end
partner_ability.rb
can :manage, Damage, :car_id => #partner.car_ids
can :create, Damage
Stack Trace:
Started POST "/cars/1/damages" for 127.0.0.1 at 2016-01-28 22:55:22 -0500
Processing by DamagesController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"gc5CPvSxAjwJfX4ekjEuJ1eZml9aoPxQWPfTBC2/kfc=", "damage"=>{"date_of_damage"=>"01/28/2016 10:55 PM", "description"=>"test"}, "commit"=>"Submit", "car_id"=>"1"}
Completed 500 Internal Server Error in 5ms
ArgumentError - argument out of range:
activesupport (4.1.4) lib/active_support/values/time_zone.rb:289:in `parse'
activesupport (4.1.4) lib/active_support/core_ext/string/zones.rb:9:in `in_time_zone'
activerecord (4.1.4) lib/active_record/attribute_methods/time_zone_conversion.rb:37:in `date_of_damage='
activerecord (4.1.4) lib/active_record/attribute_assignment.rb:45:in `_assign_attribute'
activerecord (4.1.4) lib/active_record/attribute_assignment.rb:32:in `block in assign_attributes'
activerecord (4.1.4) lib/active_record/attribute_assignment.rb:26:in `assign_attributes'
activerecord (4.1.4) lib/active_record/core.rb:455:in `init_attributes'
activerecord (4.1.4) lib/active_record/core.rb:198:in `initialize'
activerecord (4.1.4) lib/active_record/inheritance.rb:30:in `new'
cancancan (1.13.1) lib/cancan/controller_resource.rb:80:in `build_resource'
cancancan (1.13.1) lib/cancan/controller_resource.rb:61:in `load_resource_instance'
cancancan (1.13.1) lib/cancan/controller_resource.rb:32:in `load_resource'
cancancan (1.13.1) lib/cancan/controller_resource.rb:25:in `load_and_authorize_resource'
cancancan (1.13.1) lib/cancan/controller_resource.rb:10:in `block in add_before_filter'
activesupport (4.1.4) lib/active_support/callbacks.rb:440:in `block in make_lambda'
activesupport (4.1.4) lib/active_support/callbacks.rb:160:in `block in halting'
activesupport (4.1.4) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.4) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.4) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.4) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.4) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.4) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.4) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.4) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.4) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.4) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.4) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.4) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.4) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.4) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.4) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.4) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.4) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.4) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.1.4) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.4) lib/action_controller/metal.rb:232:in `block in action'
actionpack (4.1.4) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
actionpack (4.1.4) lib/action_dispatch/routing/route_set.rb:50:in `call'
actionpack (4.1.4) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.4) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.4) lib/action_dispatch/routing/route_set.rb:678:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
meta_request (0.3.4) lib/meta_request/middlewares/app_request_handler.rb:13:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
meta_request (0.3.4) lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/rack/agent_hooks.rb:30:in `traced_call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/rack/browser_monitoring.rb:32:in `traced_call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/rack/developer_mode.rb:48:in `traced_call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78: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'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
rack (1.5.5) lib/rack/etag.rb:23:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
rack (1.5.5) lib/rack/conditionalget.rb:35:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
rack (1.5.5) lib/rack/head.rb:11:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/flash.rb:254:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
rack (1.5.5) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.5) lib/rack/session/abstract/id.rb:220:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/cookies.rb:560:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
activerecord (4.1.4) lib/active_record/query_cache.rb:36:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
activerecord (4.1.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
activerecord (4.1.4) lib/active_record/migration.rb:380:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.4) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.4) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/reloader.rb:73:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.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'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
rack-contrib (1.4.0) lib/rack/contrib/response_headers.rb:17:in `call'
meta_request (0.3.4) lib/meta_request/middlewares/headers.rb:16:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
railties (4.1.4) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.4) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.4) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.4) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.4) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.4) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/request_id.rb:21:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
rack (1.5.5) lib/rack/methodoverride.rb:21:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
rack (1.5.5) lib/rack/runtime.rb:17:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
activesupport (4.1.4) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
rack (1.5.5) lib/rack/lock.rb:17:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/static.rb:64:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
rack (1.5.5) lib/rack/sendfile.rb:112:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
railties (4.1.4) lib/rails/engine.rb:514:in `call'
railties (4.1.4) lib/rails/application.rb:144:in `call'
newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call'
rack (1.5.5) lib/rack/content_length.rb:14:in `call'
thin (1.6.4) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.6.4) lib/thin/connection.rb:84:in `pre_process'
thin (1.6.4) lib/thin/connection.rb:53:in `process'
thin (1.6.4) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.8) lib/eventmachine.rb:193:in `run'
thin (1.6.4) lib/thin/backends/base.rb:73:in `start'
thin (1.6.4) lib/thin/server.rb:162:in `start'
rack (1.5.5) lib/rack/handler/thin.rb:16:in `run'
rack (1.5.5) lib/rack/server.rb:264:in `start'
railties (4.1.4) lib/rails/commands/server.rb:69:in `start'
railties (4.1.4) lib/rails/commands/commands_tasks.rb:81:in `block in server'
railties (4.1.4) lib/rails/commands/commands_tasks.rb:76:in `server'
railties (4.1.4) lib/rails/commands/commands_tasks.rb:40:in `run_command!'
railties (4.1.4) lib/rails/commands.rb:17:in `<top (required)>'
bin/rails:4:in `<main>'

Related

Adding Scope to ActiveAdmin routes getting ActionController::UrlGenerationError

I'm attempting to add a scope to the ActiveAdmin routes so that I can include the '/:brand' within the URL. SO instead of localhost:3000/admin/dashboard it would be localhost:3000/bg/admin/dashboard, with the bg being the brand.
I have my routes.rb setup like this:
Rails.application.routes.draw do
scope '/:brand', brand: /bg|gwt|acf/ do
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
end
end
The route for logging in http://localhost:3000/bg/admin/login works perfectly fine. But once logged in I'm getting the below error for any ActiveAdmin resource.
ActionController::UrlGenerationError (No route matches {:action=>"index", :controller=>"admin/dashboard"} missing required keys: [:brand]):
actionpack (5.0.0.1) lib/action_dispatch/journey/formatter.rb:50:in `generate'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:629:in `generate'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:660:in `generate'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:707:in `url_for'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:236:in `call'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:295:in `block (2 levels) in define_url_helper'
/Users/computer/.rvm/gems/ruby-2.3.1/bundler/gems/activeadmin-f8926831429f/lib/active_admin/devise.rb:40:in `root_path'
devise (4.2.0) lib/devise/controllers/helpers.rb:178:in `signed_in_root_path'
devise (4.2.0) lib/devise/controllers/helpers.rb:214:in `after_sign_in_path_for'
devise (4.2.0) app/controllers/devise_controller.rb:114:in `require_no_authentication'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:382:in `block in make_lambda'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:150:in `block (2 levels) in halting_and_conditional'
actionpack (5.0.0.1) lib/abstract_controller/callbacks.rb:12:in `block (2 levels) in <module:Callbacks>'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:454:in `block in call'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:454:in `each'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:454:in `call'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:101:in `__run_callbacks__'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.0.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.0.0.1) lib/action_controller/metal/rescue.rb:20:in `process_action'
actionpack (5.0.0.1) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (5.0.0.1) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (5.0.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.0.0.1) lib/active_support/notifications.rb:164:in `instrument'
actionpack (5.0.0.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (5.0.0.1) lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
activerecord (5.0.0.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (5.0.0.1) lib/abstract_controller/base.rb:126:in `process'
actionview (5.0.0.1) lib/action_view/rendering.rb:30:in `process'
actionpack (5.0.0.1) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (5.0.0.1) lib/action_controller/metal.rb:262:in `dispatch'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (5.0.0.1) lib/action_dispatch/routing/mapper.rb:16:in `block in <class:Constraints>'
actionpack (5.0.0.1) lib/action_dispatch/routing/mapper.rb:46:in `serve'
actionpack (5.0.0.1) lib/action_dispatch/journey/router.rb:39:in `block in serve'
actionpack (5.0.0.1) lib/action_dispatch/journey/router.rb:26:in `each'
actionpack (5.0.0.1) lib/action_dispatch/journey/router.rb:26:in `serve'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:725:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/rack/agent_hooks.rb:30:in `traced_call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/rack/browser_monitoring.rb:32:in `traced_call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/rack/developer_mode.rb:48:in `traced_call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
warden (1.2.6) lib/warden/manager.rb:35:in `block in call'
warden (1.2.6) lib/warden/manager.rb:34:in `catch'
warden (1.2.6) lib/warden/manager.rb:34:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/etag.rb:25:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/conditional_get.rb:25:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/head.rb:12:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/session/abstract/id.rb:222:in `context'
rack (2.0.1) lib/rack/session/abstract/id.rb:216:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/cookies.rb:613:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
activerecord (5.0.0.1) lib/active_record/migration.rb:552:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.0.1) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
web-console (3.3.1) lib/web_console/middleware.rb:131:in `call_app'
web-console (3.3.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (3.3.1) lib/web_console/middleware.rb:18:in `catch'
web-console (3.3.1) lib/web_console/middleware.rb:18:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
railties (5.0.0.1) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:70:in `block in tagged'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:70:in `tagged'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/request_id.rb:24:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/method_override.rb:22:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/runtime.rb:22:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack-timeout (0.4.2) lib/rack/timeout/core.rb:122:in `block in call'
rack-timeout (0.4.2) lib/rack/timeout/support/timeout.rb:19:in `timeout'
rack-timeout (0.4.2) lib/rack/timeout/core.rb:121:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
activesupport (5.0.0.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/static.rb:136:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack-cors (0.4.0) lib/rack/cors.rb:80:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/sendfile.rb:111:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
railties (5.0.0.1) lib/rails/engine.rb:522:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
puma (3.6.0) lib/puma/configuration.rb:225:in `call'
puma (3.6.0) lib/puma/server.rb:578:in `handle_request'
puma (3.6.0) lib/puma/server.rb:415:in `process_client'
puma (3.6.0) lib/puma/server.rb:275:in `block in run'
puma (3.6.0) lib/puma/thread_pool.rb:116:in `block in spawn_thread'
Rendering /Users/computer/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout
Rendering /Users/computer/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb
Rendered /Users/computer/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (4.3ms)
Rendering /Users/computer/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
Rendered /Users/computer/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.7ms)
Rendering /Users/computer/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
Rendered /Users/computer/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.0ms)
Rendered /Users/computer/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (103.9ms)
source=rack-timeout id=da53bfbfe078024cf2939732b0756051 timeout=3100000ms service=578ms state=completed
Anyone have any idea why this is happening or a way to get around it? Any help is greatly appreciated. Thanks!
Found the issue. Feel a bit silly about this, but I was using a forked repo of the original ActiveAdmin. When I switched over to use the latest from the original ActiveAdmin everything works exactly like I expected it to.
Just in case someone runs into the same issue, I was using https://github.com/dtaniwaki/active_admin, which hasnt' been updated in over 4 years.
Your error is telling you that no route exists for the url you are trying to visit.
No route matches {:action=>"index", :controller=>"admin/dashboard"} missing required keys: [:brand]
Specifically, you're missing the :brand.
Where are you redirecting to after successful sign in?
It should look something like admin_root_path(brand: 'bg'). And every path helper you invoke will need to specify that :brand param.
This error sometimes indicates there is some error in some path definition,
I was defining the wrong path for the logout path for the admin session and thus got this error.

Unable to use CanCanCan with ActiveAdmin and Devise undefined method `dashboards' for #<AdminUser>

I'm constructing an admin panel with active admin
I've installed the three gems
gem 'activeadmin', github: 'activeadmin'
gem 'devise'
gem 'cancancan'
I set it up as follows:
rails g active_admin:install # Created a nice admin panel, with AdminUser Model
rails generate active_admin:resource MyModel # Added all my models
config/active_admin.rb
config.authorization_adapter = ActiveAdmin::CanCanAdapter
config.cancan_ability_class = Ability
config.authentication_method = :authenticate_admin_user!
ability.rb
class Ability
include CanCan::Ability
def initialize(user)
if user.admin?
can :read, ActiveAdmin::Page, :name => "Dashboard"
else
can :read, ActiveAdmin::Page, :name => "Dashboard"
end
end
end
and I also defined nice custom methods using formtastic, like index, show, edit, etc. methods for all my resource models I generated for active admin.
For example, my admin/dashboard.rb
ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
# some tables to display
content title: proc{ I18n.t("active_admin.dashboard") } do
div class: "blank_slate_container", id: "dashboard_default_message" do
columns do
column do
panel "Latest Visitors" do
# table_for Visitor('id desc').limit(10) do
table_for Patient.order("id desc").limit(10) do
column(:name)
column(:mobile)
end
end
end
end # columns
end
end # content
controller do
# before_action :authenticate_admin_user!
load_and_authorize_resource :through => :current_admin_user
end
end
The app runs fine if I comment out load_and_authorize_resource, a nice login system, which shows dashboard on successful log in details.
But when I use "load_and_authorize_resource", it throws an error when I load https://mywebsite/admin saying
NoMethodError in Admin::DashboardController#index
undefined method `dashboards' for #<AdminUser:0x007f0afd642878>
The method initialize seems to be working fine. But it somehow doesn't redirect back properly to the dashboard.
I didn't specifically use devise, but when I ran rails g active_admin:install initially, when setting up activeadmin, it automatically used devise, done as per the activeadmin documentation.
Update Stack trace:
Processing by Admin::DashboardController#index as HTML
AdminUser Load (50.8ms) SELECT "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = $1 ORDER BY "admin_users"."id" ASC LIMIT $2 [["id", 2], ["LIMIT", 1]]
Completed 500 Internal Server Error in 106ms (ActiveRecord: 50.8ms)
NoMethodError (undefined method `dashboards' for #<AdminUser:0x000000063c4fa0>):
activemodel (5.0.6) lib/active_model/attribute_methods.rb:433:in `method_missing'
cancancan (2.0.0) lib/cancan/controller_resource.rb:201:in `resource_base_through'
cancancan (2.0.0) lib/cancan/controller_resource.rb:190:in `resource_base'
cancancan (2.0.0) lib/cancan/controller_resource.rb:72:in `load_collection?'
cancancan (2.0.0) lib/cancan/controller_resource.rb:36:in `load_resource'
cancancan (2.0.0) lib/cancan/controller_resource.rb:28:in `load_and_authorize_resource'
cancancan (2.0.0) lib/cancan/controller_resource.rb:12:in `block in add_before_action'
activesupport (5.0.6) lib/active_support/callbacks.rb:398:in `instance_exec'
activesupport (5.0.6) lib/active_support/callbacks.rb:398:in `block in make_lambda'
activesupport (5.0.6) lib/active_support/callbacks.rb:169:in `block (2 levels) in halting'
actionpack (5.0.6) lib/abstract_controller/callbacks.rb:12:in `block (2 levels) in <module:Callbacks>'
activesupport (5.0.6) lib/active_support/callbacks.rb:170:in `block in halting'
activesupport (5.0.6) lib/active_support/callbacks.rb:454:in `block in call'
activesupport (5.0.6) lib/active_support/callbacks.rb:454:in `each'
activesupport (5.0.6) lib/active_support/callbacks.rb:454:in `call'
activesupport (5.0.6) lib/active_support/callbacks.rb:101:in `__run_callbacks__'
activesupport (5.0.6) lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
activesupport (5.0.6) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.6) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.0.6) lib/action_controller/metal/rescue.rb:20:in `process_action'
actionpack (5.0.6) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (5.0.6) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (5.0.6) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.0.6) lib/active_support/notifications.rb:164:in `instrument'
actionpack (5.0.6) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (5.0.6) lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
activerecord (5.0.6) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (5.0.6) lib/abstract_controller/base.rb:126:in `process'
actionview (5.0.6) lib/action_view/rendering.rb:30:in `process'
actionpack (5.0.6) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (5.0.6) lib/action_controller/metal.rb:262:in `dispatch'
actionpack (5.0.6) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (5.0.6) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (5.0.6) lib/action_dispatch/journey/router.rb:39:in `block in serve'
actionpack (5.0.6) lib/action_dispatch/journey/router.rb:26:in `each'
actionpack (5.0.6) lib/action_dispatch/journey/router.rb:26:in `serve'
actionpack (5.0.6) lib/action_dispatch/routing/route_set.rb:727:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/rack/agent_hooks.rb:30:in `traced_call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/rack/browser_monitoring.rb:32:in `traced_call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
warden (1.2.7) lib/warden/manager.rb:36:in `block in call'
warden (1.2.7) lib/warden/manager.rb:35:in `catch'
warden (1.2.7) lib/warden/manager.rb:35:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
rack (2.0.3) lib/rack/etag.rb:25:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
rack (2.0.3) lib/rack/conditional_get.rb:25:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
rack (2.0.3) lib/rack/head.rb:12:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
rack (2.0.3) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.3) lib/rack/session/abstract/id.rb:226:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.0.6) lib/action_dispatch/middleware/cookies.rb:613:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
activerecord (5.0.6) lib/active_record/migration.rb:553:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.0.6) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
activesupport (5.0.6) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
activesupport (5.0.6) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
activesupport (5.0.6) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.6) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.0.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.0.6) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
better_errors (2.4.0) lib/better_errors/middleware.rb:59:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.0.6) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
web-console (3.5.1) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.5.1) lib/web_console/middleware.rb:20:in `block in call'
web-console (3.5.1) lib/web_console/middleware.rb:18:in `catch'
web-console (3.5.1) lib/web_console/middleware.rb:18:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.0.6) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
railties (5.0.6) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.6) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.6) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.0.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.6) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.0.6) lib/rails/rack/logger.rb:24:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.0.6) lib/action_dispatch/middleware/request_id.rb:24:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
rack (2.0.3) lib/rack/method_override.rb:22:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
rack (2.0.3) lib/rack/runtime.rb:22:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
activesupport (5.0.6) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.0.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.0.6) lib/action_dispatch/middleware/static.rb:136:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
railties (5.0.6) lib/rails/engine.rb:522:in `call'
newrelic_rpm (4.5.0.337) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
puma (3.10.0) lib/puma/configuration.rb:225:in `call'
puma (3.10.0) lib/puma/server.rb:605:in `handle_request'
puma (3.10.0) lib/puma/server.rb:437:in `process_client'
puma (3.10.0) lib/puma/server.rb:301:in `block in run'
puma (3.10.0) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
Rendering /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout
Rendering /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_source.html.erb
Rendered /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (4.6ms)
Rendering /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
Rendered /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.2ms)
Rendering /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
Rendered /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.0ms)
Rendered /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (35.2ms)
If you follow the steps for integrating Cancancan with ActiveAdmin, then you just have to extend Ability#initialize with your user roles as you need like so:
# app/models/ability.rb
def initialize(user)
if user.admin?
can :manage, :all
elsif user.product_manager?
can :manage, Product
can :read, ActiveAdmin::Page, name: 'Dashboard'
end
end
No need to invoke load_and_authorize_resource in each controller!

Moved a Rails app to EC2 and now my file uploads get a Encoding::UndefinedConversionError ("\xC3" from ASCII-8BIT to UTF-8) error

I've got a Rails app that has been live for over a year with no issues, running on a custom Ubuntu/Nginx/Puma setup.
Because of various issues with the hosting company, I moved the app over to EC2 this weekend - using ElasticBeanstalk on their Nginx/Puma/Ruby2.2 stack.
Everything is working fine - apart from file uploads.
The app itself uses the Paperclip gem for handling attachments - the actual files are only held momentarily in Paperclip, before being uploaded to a file-server controlled by my client (the very first version used S3 for storage, but now it uploads, attaches the "Job-Sheet" to the Job and then immediately uploads the "Job-Sheet" to the file-server).
As I say, this was all working fine on my old server. But now, on EC2, I'm getting a Encoding::UndefinedConversionError ("\xC3" from ASCII-8BIT to UTF-8) error.
The job sheet itself can be an Excel file or a CSV. It is defined as follows:
class Job < ActiveRecord::Base
...
has_attached_file :job_sheet
validates_attachment_file_name :job_sheet, matches: [/csv\Z/, /xls\Z/, /xlsx\Z/]
validates_attachment_presence :job_sheet
...
end
The controller looks like this:
class JobsController < ApplicationController
...
def create
#job = services['creates_job'].create_job job_params, session: current_session
redirect_to jobs_path
rescue ActiveRecord::RecordInvalid
...
end
...
end
The jobs_params does the StrongParams thing of permitting the parameters as required.
And the CreatesJob service object looks like:
def create_job params, session: nil
...
job = services['jobs'].create! params.merge(code: code)
...
end
So apart from the fact that the actual logic is in a separate "CreatesJob" class, there's nothing unusual going on - pretty much a standard Rails/Paperclip upload situation.
However, some uploads are failing, with the following in the production log:
I, [2016-03-22T10:12:58.701172 #23116] INFO -- : Started POST "/jobs" for 80.0.249.70 at 2016-03-22 10:12:58 +0000
F, [2016-03-22T10:12:58.706190 #23116] FATAL -- : Encoding::UndefinedConversionError ("\xC3" from ASCII-8BIT to UTF-8):
actionpack (4.2.0) lib/action_dispatch/http/upload.rb:31:in `encode'
actionpack (4.2.0) lib/action_dispatch/http/upload.rb:31:in `initialize'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:51:in `new'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:51:in `normalize_encode_params'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:57:in `block in normalize_encode_params'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:53:in `each'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:53:in `each_with_object'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:53:in `normalize_encode_params'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:57:in `block in normalize_encode_params'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:53:in `each'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:53:in `each_with_object'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:53:in `normalize_encode_params'
actionpack (4.2.0) lib/action_dispatch/http/request.rb:308:in `POST'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:14:in `parameters'
actionpack (4.2.0) lib/action_dispatch/http/filter_parameters.rb:37:in `filtered_parameters'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:22: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 `call'
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 `each'
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'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/rack/agent_hooks.rb:30:in `traced_call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/rack/browser_monitoring.rb:23:in `traced_call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
rack (1.6.1) lib/rack/etag.rb:24:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
rack (1.6.1) lib/rack/conditionalget.rb:38:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
rack (1.6.1) lib/rack/head.rb:13:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
rack (1.6.1) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.1) lib/rack/session/abstract/id.rb:220:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67: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 `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'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67: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'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
rack (1.6.1) lib/rack/methodoverride.rb:22:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
rack (1.6.1) lib/rack/runtime.rb:18:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
rack (1.6.1) lib/rack/sendfile.rb:113:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
railties (4.2.0) lib/rails/engine.rb:518:in `call'
railties (4.2.0) lib/rails/application.rb:164:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
puma (2.11.0) lib/puma/configuration.rb:82:in `call'
puma (2.11.0) lib/puma/server.rb:507:in `handle_request'
puma (2.11.0) lib/puma/server.rb:375:in `process_client'
puma (2.11.0) lib/puma/server.rb:262:in `block in run'
puma (2.11.0) lib/puma/thread_pool.rb:104:in `call'
puma (2.11.0) lib/puma/thread_pool.rb:104:in `block in spawn_thread'
The other answers related to this error all seem to be about forcing the encoding of the file. But the issue here seems to be 1) sometimes it's a binary (xls) and sometimes text (csv) so I can't go around mangling it and 2) the exception is in ActionDispatch; so looks like it's happening before I get to see the upload.
Any ideas what's going on and what I can do to fix it?
UPDATE: I can now reproduce the issue consistently. If I upload an XLSX file with an English filename, the upload works OK, if it's an XLSX file with Spanish accented in the filename, the upload fails as shown above.
The line in question is #original_filename.encode!(Encoding::UTF_8) in action_dispatch/http/upload.rb - however, the filename should be valid unicode, but it's obviously getting mangled in transit somewhere.

Rails 3 to 4 wrong number of arguments error for empty hash argument

I'm having a problem updating params after I switched to strong params. I'm getting a wrong number of arguments error, here's the trace:
Started PATCH "/profiles/rails/about_me" for 127.0.0.1 at 2014-09-23 12:14:19 -0700
Processing by UsersController#about_me as
Parameters: {"utf8"=>"✓", "user"=>{"about_me"=>"testt"}, "commit"=>"Update Biography", "id"=>"rails"}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."deleted" = 'f' AND "users"."id" = 10 ORDER BY "users"."id" ASC LIMIT 1
(0.2ms) SELECT COUNT(*) FROM "terms" INNER JOIN "terms_users" ON "terms"."id" = "terms_users"."term_id" WHERE "terms_users"."user_id" = $1 AND "terms"."name" = 'application' [["user_id", 10]]
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."deleted" = 'f' AND "users"."slug" = 'rails' ORDER BY "users"."id" ASC LIMIT 1
Completed 500 Internal Server Error in 14ms
127.0.0.1 POST /profiles/rails/about_me 500 Internal Server Error UsersController#about_me JS 13.8 (DB 0.0, View 0.0) {"utf8"=>"✓", "user"=>{"about_me"=>"testt"}, "commit"=>"Update Biography", "id"=>"rails"} {}
** [Airbrake] Notice was not sent due to configuration:
Environment Monitored? false
API key set? true
ArgumentError - wrong number of arguments (2 for 1):
app/models/user.rb:347:in `update_profile'
app/controllers/users_controller.rb:173:in `shared_update'
app/controllers/users_controller.rb:72:in `about_me'
actionpack (4.1.6) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.6) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.6) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.6) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.6) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.6) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.6) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.6) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.6) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.6) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.6) lib/action_controller/metal/rescue.rb:29:in `process_action'
config/initializers/log_formatter.rb:22:in `block (2 levels) in <top (required)>'
activesupport (4.1.6) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.6) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.6) lib/active_support/notifications.rb:159:in `instrument'
config/initializers/log_formatter.rb:21:in `block in <top (required)>'
actionpack (4.1.6) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.6) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.6) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.6) lib/action_view/rendering.rb:30:in `process'
rack-mini-profiler (0.9.2) lib/mini_profiler/profiling_methods.rb:108:in `block in profile_method'
actionpack (4.1.6) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.1.6) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.6) lib/action_controller/metal.rb:232:in `block in action'
actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:50:in `call'
actionpack (4.1.6) lib/action_dispatch/journey/router.rb:73:in `block in call'
actionpack (4.1.6) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:678:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
apipie-rails (0.2.6) lib/apipie/static_dispatcher.rb:65:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
bullet (4.13.2) lib/bullet/rack.rb:12:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
apipie-rails (0.2.6) lib/apipie/extractor/recorder.rb:97:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/rack/error_collector.rb:50:in `traced_call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/rack/agent_hooks.rb:26:in `traced_call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/rack/browser_monitoring.rb:23:in `traced_call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/rack/developer_mode.rb:48:in `traced_call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55: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'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:35:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
remotipart (1.2.1) lib/remotipart/middleware.rb:27:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/flash.rb:254:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/cookies.rb:560:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
activerecord (4.1.6) lib/active_record/query_cache.rb:36:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
activerecord (4.1.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.6) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/reloader.rb:73:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
airbrake (4.1.0) lib/airbrake/rails/middleware.rb:13:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
better_errors (2.0.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (2.0.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (2.0.0) lib/better_errors/middleware.rb:57:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
railties (4.1.6) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.6) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.6) lib/rails/rack/logger.rb:20:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/request_id.rb:21:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
activesupport (4.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/static.rb:64:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
heroku-deflater (0.5.3) lib/heroku-deflater/skip_binary.rb:19:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/deflater.rb:25:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
heroku-deflater (0.5.3) lib/heroku-deflater/serve_zipped_assets.rb:50:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
airbrake (4.1.0) lib/airbrake/user_informer.rb:16:in `_call'
airbrake (4.1.0) lib/airbrake/user_informer.rb:12:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack-mini-profiler (0.9.2) lib/mini_profiler/profiler.rb:300:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
railties (4.1.6) lib/rails/engine.rb:514:in `call'
railties (4.1.6) lib/rails/application.rb:144:in `call'
railties (4.1.6) lib/rails/railtie.rb:194:in `method_missing'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
thin (1.6.2) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.6.2) lib/thin/connection.rb:84:in `pre_process'
thin (1.6.2) lib/thin/connection.rb:53:in `process'
thin (1.6.2) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
thin (1.6.2) lib/thin/backends/base.rb:73:in `start'
thin (1.6.2) lib/thin/server.rb:162:in `start'
rack (1.5.2) lib/rack/handler/thin.rb:16:in `run'
rack (1.5.2) lib/rack/server.rb:264:in `start'
railties (4.1.6) lib/rails/commands/server.rb:69:in `start'
railties (4.1.6) lib/rails/commands/commands_tasks.rb:81:in `block in server'
railties (4.1.6) lib/rails/commands/commands_tasks.rb:76:in `server'
railties (4.1.6) lib/rails/commands/commands_tasks.rb:40:in `run_command!'
railties (4.1.6) lib/rails/commands.rb:17:in `<top (required)>'
script/rails:6:in `<main>'
User.rb:347:update_profile:
def update_profile(attributes, options = {})
return false if attributes.nil?
previous_avatar = !has_default_avatar?
assign_attributes(attributes, options)
if valid?
if about_me_changed? || attributes[:avatar]
uploaded_avatar = (attributes[:avatar].nil?)? false : true
BadgesStrategies::Profile.assign_based_on(self, about_me: [about_me_was, about_me], avatar: [previous_avatar, uploaded_avatar])
end
end
save
end
UsersController:shared_update:
def shared_update
params[:user].delete(:password) if params[:user] && params[:user][:password].blank?
params[:user].delete(:password_confirmation) if params[:user] && params[:user][:password].blank? and params[:user][:password_confirmation].blank?
email_changed = params[:user] && params[:user][:email] && #user.email != params[:user][:email]
if #user.update_profile(user_params)
sign_in #user, bypass: true
if email_changed
if #user.pending_reconfirmation?
flash[:notice] = "Success! Please check '#{params[:user][:email]}' for instructions to complete the update process."
else
flash[:notice] = "Successfully changed to '#{params[:user][:email]}'"
end
else
flash[:notice] = "Your profile is successfully updated"
end
else
flash[:alert] = (params[:user].nil? )? "ERROR: No user information sent for update" : "ERROR: #{#user.errors.full_messages.to_sentence}"
end
end
UsersController:about_me:
def about_me
shared_update
render partial: 'users/about_me', locals: { user: #user }
end
Could somebody look through this and tell me what exactly is going wrong? Is it a syntax error in Rails 4?
If user.rb line 347 is this line:
assign_attributes(attributes, options)
Then there's your problem. ActiveRecord#assign_attributes appears to only take one argument in Rails 4.
See docs here
Rails 3's API for the method did allow an options hash. See docs here.
In rails 3, the options seems to have handled access control allowing to configure who was able to do mass assignment. In rails 4 with strong params, that responsibility has shifted to the param hash itself.
The rails 4 docs state:
If the passed hash responds to permitted? method and the return value of this method is false an ActiveModel::ForbiddenAttributesError exception is raised.
In conclusion, when you get a message telling you that you aren't passing the right arguments to a method, the first thing you do should be to look up that method in the documentation and see how you are supposed to use it.
I had no idea when I read this question what the answer was. I just found the method that you were passing two arguments into you your code, and then looked up the docs and the answer was pretty clear.

Rails partial update ActionController::UnknownFormat

I'm trying to update a partial. Everything worked perfectşy in Rails 3 but now bumped to Rails 4.1 and I'm getting the ActionController::UnknownFormat error. I'm placing _form.html.haml into bootstrap 3 modal.
aprs_controller.rb (** is the place code gets into and I get the error)
class AprsController < ApplicationController
include Transloadit::Rails::ParamsDecoder
include AprsHelper
respond_to :html, :json, :js
def update
app = App.where('events._id' => BSON::ObjectId.from_string(params[:eventid])).first
unless app.check_user_failed == true
event = app.events.detect { |pr| pr.id.to_s == params[:eventid] }
apr = event.aprs.detect { |pr| pr.id.to_s == params[:id] }
isvalid = check_video_validity(params[:transloadit], event)
if isvalid == true
videos = transloadit_file_uploads(params[:transloadit], apr.upload)
#aprs=nil
if videos.present?
apr.upload = nil
apr.upload = videos
else
flash.now[:error] = "The time of video is wrong"
return
end
if apr.save
event = app.events.detect { |pr| pr.id.to_s == params[:eventid] }
blank = event.aprs.map{|evt| evt.upload; evt.upload.blank?}
unless blank.include? true
event.status = 4
event.save
end
**respond_to do |format|
#aprs = event.aprs
format.js
end**
end
else
flash.now[:error] = "vieo is not valid"
respond_to do |format|
#aprs = nil
format.js
end
end
else
flash.now[:error] = "user failed"
end
end
private
def apr_params
params.required(:apr).permit(:upload)
end
end
update.js.erb
$('#update_container').html("<%= j render 'form', :locals => {:aprs => #aprs} %>");
routes
resources :aprs
_form.html.haml
#update_container
- if #aprs.present?
- #aprs.each_with_index do |apr,index|
= bootstrap_form_for apr, :remote=> true, html: {"data-remote" => 'true', 'data-method' => 'post', :id => "showapr#{apr.id}" , "data-type" => :json, class: 'form-horizontal' } do |f|
= hidden_field_tag :eventid, apr.event.id
= transloadit :video_encode
.fileupload.fileupload-new.pull-left{"data-provides" => "fileupload", style: "padding-right: 5px;"}
.fileupload-preview.thumbnail{:style => "width: 140px; height: 140px;"}
- if apr.upload.present?
- if apr.upload["thumbs"].present?
%img{ :src => apr.upload["thumbs"][0], :style => "width: 140px;height: 140px;"}
-else
%img{"data-src" => "holder.js/140x140/text:Lorem ipsum/social", :src => "", :style => "width: 140px;height: 140px;"}/
- if apr.event.app.check_user_failed == false && (apr.event.start_time.day == Time.zone.now.day)
%div
%span.btn.btn-default.btn-file
%span.fileupload-new Select image
=f.file_field "upload#{apr.id}" , accept: 'video/flv,video/avi,video/mov,video/mp4,video/mpg,video/wmv,video/3gp,video/asf,video/rm,video/swf', :data => {:max_file_size => 30.megabytes}
= transloadit_jquerify "showapr#{apr.id}", :wait => true, :modal=>true, :triggerUploadOnFileSelection=> true
-else
= label_tag :error_label, "time doesn't fit to update time", class: 'control-label'
Produces this error:
ActionController::UnknownFormat - ActionController::UnknownFormat:
actionpack (4.1.6) lib/action_controller/metal/mime_responds.rb:440:in `retrieve_collector_from_mimes'
actionpack (4.1.6) lib/action_controller/metal/mime_responds.rb:256:in `respond_to'
app/controllers/aprs_controller.rb:40:in `update'
actionpack (4.1.6) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.6) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.6) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.6) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.
I registered all mime types too(even they are registered)
Mime::Type.register "text/html", :html, %w( application/xhtml+xml ), %w( xhtml )
Mime::Type.register "text/plain", :text, [], %w(txt)
Mime::Type.register "text/javascript", :js,
%w(application/javascript application/x-javascript)
Mime::Type.register "text/css", :css
Mime::Type.register "text/calendar", :ics
Mime::Type.register "text/csv", :csv
Mime::Type.register "image/png", :png, [], %w(png)
Mime::Type.register "image/jpeg", :jpeg, [], %w(jpg jpeg jpe pjpeg)
Mime::Type.register "image/gif", :gif, [], %w(gif)
Mime::Type.register "image/bmp", :bmp, [], %w(bmp)
Mime::Type.register "image/tiff", :tiff, [], %w(tif tiff)
Mime::Type.register "video/mpeg", :mpeg, [], %w(mpg mpeg mpe)
Mime::Type.register "application/xml", :xml, %w(text/xml application/x-xml)
Mime::Type.register "application/rss+xml", :rss
Mime::Type.register "application/atom+xml", :atom
Mime::Type.register "application/x-yaml", :yaml, %w( text/yaml )
Mime::Type.register "multipart/form-data", :multipart_form
Mime::Type.register "application/x-www-form-urlencoded", :url_encoded_form
Mime::Type.register "application/json", :json,
%w(text/x-json application/jsonrequest)
Mime::Type.register "application/pdf", :pdf, [], %w(pdf)
Mime::Type.register "application/zip", :zip, [], %w(zip)
Everything used to work in rails 3 didn't change the code.
Server log after the update action
Completed 200 OK in 320ms (Views: 308.7ms)
Started PATCH "/aprs/5429cf4663616e0f6d100000" for 127.0.0.1 at 2014-09-30 00:30:18 +0300
Processing by AprsController#update as HTML
Parameters: {"transloadit"=>"{\"ok\":\"ASSEMBLY_COMPLETED\",\"message\":\"The assembly was successfully completed.\",\"assembly_id\":\"c0bbb2b0481f11e4bb7fe3cde209aa37\",\"parent_id\":null,\"assembly_url\":\"http://api2.ebeny.transloadit.com/assemblies/c0bbb2b0481f11e4bb7fe3cde209aa37\",\"assembly_ssl_url\":\"https://ebeny.transloadit.com/assemblies/c0bbb2b0481f11e4bb7fe3cde209aa37\",\"bytes_received\":258018,\"bytes_expected\":258018,\"client_agent\":\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/36.0.1985.125 Chrome/36.0.1985.125 Safari/537.36\",\"client_ip\":\"85.100.75.234\",\"client_referer\":\"http://0.0.0.0:3000/apps/5429cf4563616e0f6d010000\",\"start_date\":\"2014/09/29 21:29:54 GMT\",\"is_infinite\":false,\"has_dupe_jobs\":false,\"upload_duration\":4.538,\"execution_start\":\"2014/09/29 21:29:59 GMT\",\"execution_duration\":18.362,\"notify_start\":null,\"notify_url\":null,\"notify_status\":null,\"last_job_completed\":\"2014/09/29 21:30:17 GMT\",\"notify_duration\":null,\"fields\":{},\"running_jobs\":[],\"bytes_usage\":1374741,\"executing_jobs\":[],\"started_jobs\":[],\"files_to_store_on_s3\":0,\"queued_files_to_store_on_s3\":0,\"parent_assembly_status\":null,\"params\":\"{\\\"template_id\\\":\\\"8f64b330a16f11e394d06b3e241b8964\\\"}\",\"uploads\":[{\"id\":\"c3485100481f11e494cc9bab5ef2bbe3\",\"name\":\"IMG_1561.MOV\",\"basename\":\"IMG_1561\",\"ext\":\"mov\",\"size\":257409,\"mime\":\"video/quicktime\",\"type\":\...........
flags=[]
COMMAND database=approachmachine_development command={:getlasterror=>1, :w=>1} runtime: 2.2516ms
Completed 406 Not Acceptable in 80ms
ActionController::UnknownFormat - ActionController::UnknownFormat:
actionpack (4.1.6) lib/action_controller/metal/mime_responds.rb:440:in `retrieve_collector_from_mimes'
actionpack (4.1.6) lib/action_controller/metal/mime_responds.rb:256:in `respond_to'
app/controllers/aprs_controller.rb:30:in `update'
actionpack (4.1.6) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.6) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.6) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.6) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:282:in `block (2 levels) in halting_and_conditional'
activesupport (4.1.6) lib/active_support/core_ext/time/zones.rb:47:in `use_zone'
app/controllers/application_controller.rb:23:in `set_user_time_zone'
activesupport (4.1.6) lib/active_support/callbacks.rb:424:in `block in make_lambda'
activesupport (4.1.6) lib/active_support/callbacks.rb:281:in `block in halting_and_conditional'
activesupport (4.1.6) lib/active_support/callbacks.rb:299:in `block (2 levels) in halting'
i18n (0.6.11) lib/i18n.rb:256:in `with_locale'
app/controllers/application_controller.rb:19:in `set_locale'
activesupport (4.1.6) lib/active_support/callbacks.rb:424:in `block in make_lambda'
activesupport (4.1.6) lib/active_support/callbacks.rb:298:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.6) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.6) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.6) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.6) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.6) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.6) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.6) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.6) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
actionpack (4.1.6) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.6) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.6) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.1.6) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.6) lib/action_controller/metal.rb:232:in `block in action'
actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:50:in `call'
actionpack (4.1.6) lib/action_dispatch/journey/router.rb:73:in `block in call'
actionpack (4.1.6) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:678:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
meta_request (0.3.4) lib/meta_request/middlewares/app_request_handler.rb:13:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
meta_request (0.3.4) lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
bullet (4.13.2) lib/bullet/rack.rb:12:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
i18n-js (2.1.2) lib/i18n-js/middleware.rb:11:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack-mobile-detect (0.4.0) lib/rack/mobile-detect.rb:164:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
http_accept_language (2.0.2) lib/http_accept_language/middleware.rb:13:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/rack/error_collector.rb:50:in `traced_call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/rack/agent_hooks.rb:26:in `traced_call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/rack/browser_monitoring.rb:23:in `traced_call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/rack/developer_mode.rb:48:in `traced_call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55: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'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
() home/caner/.rvm/gems/ruby-2.1.2/bundler/gems/client_side_validations-e431ba00e2d7/lib/client_side_validations/middleware.rb:17:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:35:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/flash.rb:254:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/cookies.rb:560:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.6) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/reloader.rb:73:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
better_errors (2.0.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (2.0.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (2.0.0) lib/better_errors/middleware.rb:57:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack-contrib (1.1.0) lib/rack/contrib/response_headers.rb:17:in `call'
meta_request (0.3.4) lib/meta_request/middlewares/headers.rb:16:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
railties (4.1.6) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.6) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.6) lib/rails/rack/logger.rb:20:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/request_id.rb:21:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
activesupport (4.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/static.rb:64:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
railties (4.1.6) lib/rails/engine.rb:514:in `call'
railties (4.1.6) lib/rails/application.rb:144:in `call'
railties (4.1.6) lib/rails/railtie.rb:194:in `method_missing'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
thin (1.6.2) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.6.2) lib/thin/connection.rb:84:in `pre_process'
thin (1.6.2) lib/thin/connection.rb:53:in `process'
thin (1.6.2) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
thin (1.6.2) lib/thin/backends/base.rb:73:in `start'
thin (1.6.2) lib/thin/server.rb:162:in `start'
rack (1.5.2) lib/rack/handler/thin.rb:16:in `run'
rack (1.5.2) lib/rack/server.rb:264:in `start'
railties (4.1.6) lib/rails/commands/server.rb:69:in `start'
railties (4.1.6) lib/rails/commands/commands_tasks.rb:81:in `block in server'
railties (4.1.6) lib/rails/commands/commands_tasks.rb:76:in `server'
railties (4.1.6) lib/rails/commands/commands_tasks.rb:40:in `run_command!'
railties (4.1.6) lib/rails/commands.rb:17:in `<top (required)>'
bin/rails:4:in `<main>'
Try this if this works for you..
I have done something like this in my app.
respond_to :html, :json, :js
..................................
respond_with(#users) do |format|
format.json { render :json => #user.as_json }
format.html
format.js
end

Resources