Active Admin Editor not running - ruby

I am trying to include an editor in an Active Admin setting.
I am able to bundle install every version of it up to 1.1.0, but when I run rails s and try to access the admin page I get the following error:
Sass::SyntaxError in Admin/keywords#index
Showing /Users/xxxxx/.rvm/gems/xxxxx/gems/activeadmin-0.6.0/app/views/active_admin/resource/index.html.arb where line #1 raised:
File to import not found or unreadable: ../functions/linear-gradient.
Load path: Sass::Rails::Importer(/Users/xxxxx/.rvm/gems/xxxxx/gems/active_admin_editor-1.0.5/app/assets/stylesheets/active_admin/editor.css.scss)
(in /Users/xxxxx/.rvm/gems/xxxxx/gems/active_admin_editor-1.0.5/app/assets/stylesheets/active_admin/editor.css.scss)
ActionView::Template::Error (File to import not found or unreadable: ../functions/linear-gradient.
Load path: Sass::Rails::Importer(/Users/xxxx/.rvm/gems/xxxx/gems/active_admin_editor-1.0.5/app/assets/stylesheets/active_admin/editor.css.scss)
(in /Users/xxxx/.rvm/gems/xxxx/gems/active_admin_editor-1.0.5/app/assets/stylesheets/active_admin/editor.css.scss)):
1: insert_tag renderer_for(:index)
bourbon (1.0.4) app/assets/stylesheets/css3/_background-image.scss:5
bourbon (1.0.4) app/assets/stylesheets/_bourbon.scss:9
activeadmin (0.6.0) app/assets/stylesheets/active_admin/mixins/_all.css.scss:11
activeadmin (0.6.0) app/assets/stylesheets/active_admin/_mixins.css.scss:1
active_admin_editor (1.0.5) app/assets/stylesheets/active_admin/editor.css.scss:1
sass (3.1.10) lib/sass/./sass/tree/import_node.rb:64:in `import'
sass (3.1.10) lib/sass/./sass/tree/import_node.rb:25:in `imported_file'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:147:in `visit_import'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `send'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:18:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `visit_import'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `map'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `visit_import'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `send'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:18:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `visit_import'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `map'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `visit_import'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `send'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:18:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `visit_import'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `map'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:144:in `visit_import'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `send'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:18:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:53:in `visit_children'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:53:in `map'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:53:in `visit_children'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:27:in `visit_children'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:39:in `with_environment'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:26:in `visit_children'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:47:in `visit_root'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `send'
sass (3.1.10) lib/sass/./sass/tree/visitors/base.rb:37:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:18:in `visit'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:7:in `send'
sass (3.1.10) lib/sass/./sass/tree/visitors/perform.rb:7:in `visit'
sass (3.1.10) lib/sass/./sass/tree/root_node.rb:20:in `render'
sass (3.1.10) lib/sass/./sass/engine.rb:300:in `_render'
sass (3.1.10) lib/sass/./sass/engine.rb:247:in `render'
sass-rails (3.2.6) lib/sass/rails/template_handlers.rb:106:in `evaluate'
tilt (1.4.1) lib/tilt/template.rb:103:in `render'
sprockets (2.1.4) lib/sprockets/context.rb:177:in `evaluate'
sprockets (2.1.4) lib/sprockets/context.rb:174:in `each'
sprockets (2.1.4) lib/sprockets/context.rb:174:in `evaluate'
sprockets (2.1.4) lib/sprockets/processed_asset.rb:12:in `initialize'
sprockets (2.1.4) lib/sprockets/base.rb:241:in `new'
sprockets (2.1.4) lib/sprockets/base.rb:241:in `build_asset'
sprockets (2.1.4) lib/sprockets/base.rb:262:in `circular_call_protection'
sprockets (2.1.4) lib/sprockets/base.rb:240:in `build_asset'
sprockets (2.1.4) lib/sprockets/index.rb:89:in `build_asset'
sprockets (2.1.4) lib/sprockets/caching.rb:19:in `cache_asset'
sprockets (2.1.4) lib/sprockets/index.rb:88:in `build_asset'
sprockets (2.1.4) lib/sprockets/base.rb:163:in `find_asset'
sprockets (2.1.4) lib/sprockets/index.rb:56:in `find_asset'
sprockets (2.1.4) lib/sprockets/bundled_asset.rb:16:in `initialize'
sprockets (2.1.4) lib/sprockets/base.rb:244:in `new'
sprockets (2.1.4) lib/sprockets/base.rb:244:in `build_asset'
sprockets (2.1.4) lib/sprockets/index.rb:89:in `build_asset'
sprockets (2.1.4) lib/sprockets/caching.rb:19:in `cache_asset'
sprockets (2.1.4) lib/sprockets/index.rb:88:in `build_asset'
sprockets (2.1.4) lib/sprockets/base.rb:163:in `find_asset'
sprockets (2.1.4) lib/sprockets/index.rb:56:in `find_asset'
sprockets (2.1.4) lib/sprockets/environment.rb:74:in `find_asset'
sprockets (2.1.4) lib/sprockets/base.rb:171:in `[]'
actionpack (3.2.5) lib/sprockets/helpers/rails_helper.rb:126:in `asset_for'
actionpack (3.2.5) lib/sprockets/helpers/rails_helper.rb:44:in `stylesheet_link_tag'
actionpack (3.2.5) lib/sprockets/helpers/rails_helper.rb:43:in `collect'
actionpack (3.2.5) lib/sprockets/helpers/rails_helper.rb:43:in `stylesheet_link_tag'
arbre (1.0.1) lib/arbre/element.rb:175:in `send'
arbre (1.0.1) lib/arbre/element.rb:175:in `method_missing'
activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:27:in `build_active_admin_head'
activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:26:in `each'
activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:26:in `build_active_admin_head'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `within'
activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:24:in `build_active_admin_head'
activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:9:in `build'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:30:in `build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
activeadmin (0.6.0) app/views/active_admin/resource/index.html.arb:1:in `___sers__tephan__rvm_gems_ruby_______p____saftzine_gems_activeadmin_______app_views_active_admin_resource_index_html_arb___381976998_2302642480'
arbre (1.0.1) lib/arbre/context.rb:45:in `instance_eval'
arbre (1.0.1) lib/arbre/context.rb:45:in `initialize'
activeadmin (0.6.0) app/views/active_admin/resource/index.html.arb:1:in `new'
activeadmin (0.6.0) app/views/active_admin/resource/index.html.arb:1:in `___sers__tephan__rvm_gems_ruby_______p____saftzine_gems_activeadmin_______app_views_active_admin_resource_index_html_arb___381976998_2302642480'
actionpack (3.2.5) lib/action_view/template.rb:145:in `send'
actionpack (3.2.5) lib/action_view/template.rb:145:in `render'
activesupport (3.2.5) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.5) lib/action_view/template.rb:143:in `render'
.
.
.
The active-admin.css.scss is:
// SASS variable overrides must be declared before loading up Active Admin's styles.
//
// To view the variables that Active Admin provides, take a look at
// `app/assets/stylesheets/active_admin/mixins/_variables.css.scss` in the
// Active Admin source.
//
// For example, to change the sidebar width:
// $sidebar-width: 242px;
// Active Admin's got SASS!
#import "active_admin/mixins";
#import "active_admin/base";
// Overriding any non-variable SASS must be done after the fact.
// For example, to change the default status-tag color:
//
// body.active_admin {
// .status_tag { background: #6090DB; }
// }
//
// Notice that Active Admin CSS rules are nested within a
// 'body.active_admin' selector to prevent conflicts with
// other pages in the app. It is best to wrap your changes in a
// namespace so they are properly recognized. You have options
// if you e.g. want different styles for different namespaces:
//
// .active_admin applies to any Active Admin namespace
// .admin_namespace applies to the admin namespace (eg: /admin)
// .other_namespace applies to a custom namespace named other (eg: /other)
//= require active_admin/editor/wysiwyg
The only place I can find linear-gradient is in
Searching 482 files for "linear-gradient"
/Users/xxxxx/.rvm/gems/xxxxx/gems/activeadmin-0.6.0/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss:
$secondary-gradient-start: #efefef !default;
$secondary-gradient-stop: #dfe1e2 !default;
#mixin gradient($start, $end){
background: $start;
background: -webkit-linear-gradient(-90deg, $start, $end);
background: -moz-linear-gradient(-90deg, $start, $end);
background: linear-gradient(-90deg, $start, $end);
// IE 6 & 7
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{ie-hex-str($start)}', endColorstr='#{ie-hex-str($end)}');
// IE 8
-ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{ie-hex-str($start)}', endColorstr='#{ie-hex-str($end)}');
}
#mixin primary-gradient {
#include gradient(lighten($primary-color, 5%), darken($primary-color, 7%));
border-bottom: 1px solid darken($primary-color, 11%);
}
#mixin secondary-gradient {
#include gradient($secondary-gradient-start, $secondary-gradient-stop);
}
#mixin highlight-gradient {
#include gradient(#75a1c2, #608cb4);
}
#mixin reverse-highlight-gradient {
#include gradient(#608cb4, #75a1c2);
}
#mixin no-gradient {
background: none;
// IE 6 & 7
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
// IE 8
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(enabled=false)";
}
active_admin_editor-1.0.x/app/assets/stylesheets/active_admin/editor.css.scss starts with:
#import 'active_admin/mixins';
body form .html_editor {
.wrap {
width: 76%;
float: left;
}
.
.
.
Where am I missing something. How can I get this to work?

My guess is it is related to the removal of Bourbon or the removal of sass-rails. Re-adding one or both may resolve the issue.

Thanks to Piers C and some research on the AA GitHub I was able to find a solution to my problem.
The problem might be related to either Bourbon, SASS or the assets pipeline.
In my case I ended up
deleting #import "bourbon"; from
activeadmin-0.6.0/app/assets/stylesheets/mixins/_all.css.scss
adding a _box_shadow.css.scss mixin in the same folder and
importing it in _all.css.scss
editing the _gradient.css.scss mixin in AA
Now I have the following files:
activeadmin-0.6.0/app/assets/stylesheets/mixins/_all.css.scss
#import "active_admin/mixins/variables";
#import "active_admin/mixins/reset";
#import "active_admin/mixins/gradients";
#import "active_admin/mixins/shadows";
#import "active_admin/mixins/icons";
#import "active_admin/mixins/rounded";
#import "active_admin/mixins/buttons";
#import "active_admin/mixins/sections";
#import "active_admin/mixins/utilities";
#import "active_admin/mixins/typography";
#import "active_admin/mixins/box_shadow";
activeadmin-0.6.0/app/assets/stylesheets/mixins/_box_shadow.css.scss
#mixin box-shadow ($shadow-1,
$shadow-2: false, $shadow-3: false,
$shadow-4: false, $shadow-5: false,
$shadow-6: false, $shadow-7: false,
$shadow-8: false, $shadow-9: false)
{
$full: compact($shadow-1, $shadow-2, $shadow-3, $shadow-4,
$shadow-5, $shadow-6, $shadow-7, $shadow-8, $shadow-9);
-webkit-box-shadow: $full;
-moz-box-shadow: $full;
-ms-box-shadow: $full;
-o-box-shadow: $full;
box-shadow: $full;
}
activeadmin-0.6.0/app/assets/stylesheets/mixins/_gradient.css.scss
$secondary-gradient-start: #efefef !default;
$secondary-gradient-stop: #dfe1e2 !default;
#mixin gradient($start, $end) {
background-color: $start;
background-image: unquote("linear-gradient(180deg, #{$start}, #{$end})");
}
#mixin primary-gradient {
#include gradient(lighten($primary-color, 5%), darken($primary-color, 7%));
border-bottom: 1px solid darken($primary-color, 11%);
}
#mixin secondary-gradient {
#include gradient($secondary-gradient-start, $secondary-gradient-stop);
}
#mixin highlight-gradient {
#include gradient(#75a1c2, #608cb4);
}
#mixin reverse-highlight-gradient {
#include gradient(#608cb4, #75a1c2);
}
#mixin no-gradient {
background-color: none;
}
I mention step three just for completeness, since I discovered later that I did not replicate this step in production, but that everything was working nevertheless.

Related

Getting TypeError - can't clone Symbol: error when using active_model_serializer

So I have Ruby 2.1.3 with Rails 4.2.0 and I am using the active_model_serializer gem to send proper json data to AngularJs.
Not I only upgraded today from Rails 4.1.6 to 4.2.0. With the previous version the problem did not exist.
The problem appears when I try to get json from my medium show action:
def show
medium = Medium.find(params[:id])
respond_with medium, include: [{comments: :user}, :likes, :user]
end
And this is how the same action looked before I upgraded rails:
def show
medium = Medium.includes([{comments: :user}, :likes, :user]).find(params[:id])
respond_with medium
end
It used to be able to work the old way but with the new rails, it does not have the included ActiveModels with the medium anymore in the sent json data.
So I changed the code using the examples on this page: https://github.com/rails-api/active_model_serializers
Here is how my media serializer looks like:
class MediumSerializer < ActiveModel::Serializer
attributes :id,
:text,
:image_video_file_name,
:image_video_croppable_url,
:image_video_thumb_url,
:image_video_big_url
has_one :user
has_many :comments, :likes
end
Before the upgrade it looked like this:
class MediumSerializer < ActiveModel::Serializer
attributes :id,
:text,
:image_video_file_name,
:image_video_croppable_url,
:image_video_thumb_url,
:image_video_big_url
has_one :user
has_many :comments, :likes
def include_user?
object.association(:user).loaded?
end
def include_comments?
object.association(:comments).loaded?
end
def include_associations?
object.association(:user, :comments, :likes).loaded?
end
end
So, when making a query for that show action, the error that my Rails application throws is this:
Started GET "/media/7.json" for 127.0.0.1 at 2014-12-25 18:13:43 +0200
Processing by Content::MediaController#show as JSON
Parameters: {"id"=>"7"}
Medium Load (0.4ms) SELECT "media".* FROM "media" WHERE "media"."id" = $1 LIMIT 1 [["id", 7]]
Comment Load (0.5ms) SELECT "comments".* FROM "comments" WHERE "comments"."medium_id" = $1 [["medium_id", 7]]
Completed 500 Internal Server Error in 59ms
TypeError - can't clone Symbol:
activesupport (4.2.0) lib/active_support/core_ext/object/try.rb:77:in `try!'
activesupport (4.2.0) lib/active_support/core_ext/object/try.rb:63:in `try'
activerecord (4.2.0) lib/active_record/serialization.rb:12:in `serializable_hash'
activemodel (4.2.0) lib/active_model/serialization.rb:114:in `block (2 levels) in serializable_hash'
activemodel (4.2.0) lib/active_model/serialization.rb:114:in `block in serializable_hash'
activemodel (4.2.0) lib/active_model/serialization.rb:158:in `block in serializable_add_includes'
activemodel (4.2.0) lib/active_model/serialization.rb:156:in `serializable_add_includes'
activemodel (4.2.0) lib/active_model/serialization.rb:112:in `serializable_hash'
activerecord (4.2.0) lib/active_record/serialization.rb:17:in `serializable_hash'
activemodel (4.2.0) lib/active_model/serializers/json.rb:99:in `as_json'
app/models/medium.rb:32:in `as_json'
activesupport (4.2.0) lib/active_support/json/encoding.rb:34:in `encode'
activesupport (4.2.0) lib/active_support/json/encoding.rb:21:in `encode'
activesupport (4.2.0) lib/active_support/core_ext/object/json.rb:37:in `to_json_with_active_support_encoder'
actionpack (4.2.0) lib/action_controller/metal/renderers.rb:116:in `block in <module:Renderers>'
actionpack (4.2.0) lib/action_controller/metal/renderers.rb:45:in `block in _render_to_body_with_renderer'
/home/kaspar/.rbenv/versions/2.1.3/lib/ruby/2.1.0/set.rb:263:in `each'
actionpack (4.2.0) lib/action_controller/metal/renderers.rb:41:in `_render_to_body_with_renderer'
actionpack (4.2.0) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
actionpack (4.2.0) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.2.0) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.2.0) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/home/kaspar/.rbenv/versions/2.1.3/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
activesupport (4.2.0) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:40:in `render'
responders (2.0.2) lib/action_controller/responder.rb:258:in `display'
responders (2.0.2) lib/action_controller/responder.rb:212:in `api_behavior'
responders (2.0.2) lib/action_controller/responder.rb:191:in `rescue in to_format'
responders (2.0.2) lib/action_controller/responder.rb:185:in `to_format'
responders (2.0.2) lib/action_controller/responder.rb:163:in `respond'
responders (2.0.2) lib/action_controller/responder.rb:156:in `call'
responders (2.0.2) lib/action_controller/respond_with.rb:203:in `respond_with'
app/controllers/content/media_controller.rb:17:in `show'
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: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:151:in `block in halting_and_conditional'
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: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'
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.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (2.1.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (2.1.0) 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'
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'
passenger (4.0.56) lib/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
passenger (4.0.56) lib/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
passenger (4.0.56) lib/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
passenger (4.0.56) lib/phusion_passenger/request_handler.rb:455:in `block (3 levels) in start_threads'
Worth noting maybe that if I remove both of the :user includes from the new include: method, then everything works. But I want each comment to also include the user that created it and medium to also include the user that uploaded it.
What could be the problem here? Let me know if some more info is needed.
EDIT: The problem seems to be only with the :user for comments:.
Posting my comments serializer here:
class CommentSerializer < ActiveModel::Serializer
attributes :id,
:text,
:user_id,
:medium_id
has_one :user
end
I encountered the same error using the built in ActiveModel serializer for JSON. You can overwrite a model's as_json method with similar syntax to your respond_with call. Using your models I had
include: [{comments: :user} ... ]
when what I needed was
include: [{comments: {include: [:user]}}, ... ]
See if the following change fixes your problem (if you're still having it).
Change
respond_with medium, include: [{comments: :user}, :likes, :user]
to
respond_with medium, include: [{comments: {include: [:user]}}, :likes, :user]

Does Kaminari Work with Inherited Resources?

Does anyone know whether the Kaminari gem works with Inherited Resources, because I'm trying to keep my code dry and don't want to repeat myself?
What the plan is, is to render 3 different tables i.e. an Errors table, Messages table and Subscribers table using one partial. However because I'm using Inherited Resources I need all of the code that I'd use in the errors controller, messages controller and subscribers controller, to come through the Admin Application Controller.
I hope this makes sense to anyone reading this
Here's my code:
Admin Application Controller
class Admin::ApplicationController < InheritedResources::Base
protect_from_forgery
include ResourcesHelper
layout "admin"
#Setup
before_filter :set_resource_variable
before_filter :set_pagination_variable, only: :index
#Authentication
skip_before_filter :authenticate_user!
before_filter :authenticate_admin!
#Authorization
skip_before_filter :check_authentication
#Index
#Custom Index For Application/Index (no inheritance)
def index
#users = User.all
#attributes = %w(messages subscribers)
end
#Create
def create
create! { collection_path }
end
#Update
def update
update! { collection_path }
end
private
#Set Model Variable
def set_resource_variable
#resource = self.resource_class
#model = "#{#resource}".downcase.to_sym
end
#Strong Params
def permitted_params
attributes = attributes(#resource) + %w(user_id admin_id) + [image_pages_attributes: [:caption, image_attributes: [:image]]]
params.permit(#model => attributes)
end
end
Errors Controller
def collection
#errors ||= end_of_association_chain.page params[:page]
end
Table Partial
<h2><%= model %></h2>
<% unless collection.blank? %>
<table class="sort">
<thead>
<tr>
<% model.attribute_names.each do |attr| %>
<th><%= model.human_attribute_name(attr) %></th>
<% end %>
<th colspan="2"> </th>
<% if model.name == "Error" %><th> </th><% end %>
</tr>
</thead>
<tbody>
<%= render partial: "admin/resources/table/row", collection: collection, as: :resource, locals: {model: model} %>
</tbody>
</table>
Here is the stack trace.
This error was thrown due to a current_page error:
undefined method `current_page' for nil:NilClass
Stack Trace
kaminari (0.15.0) lib/kaminari/helpers/action_view_extension.rb:18:in `paginate'
app/views/admin/resources/_table.html.erb:18:in `_app_views_admin_resources__table_html_erb___69500511_4075212'
actionpack (4.0.2) lib/action_view/template.rb:143:in `block in render'
activesupport (4.0.2) lib/active_support/notifications.rb:161:in `instrument'
actionpack (4.0.2) lib/action_view/template.rb:141:in `render'
actionpack (4.0.2) lib/action_view/renderer/partial_renderer.rb:306:in `render_partial'
actionpack (4.0.2) lib/action_view/renderer/partial_renderer.rb:279:in `block in render'
actionpack (4.0.2) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.2) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (4.0.2) lib/action_view/renderer/partial_renderer.rb:278:in `render'
actionpack (4.0.2) lib/action_view/renderer/renderer.rb:47:in `render_partial'
actionpack (4.0.2) lib/action_view/renderer/renderer.rb:21:in `render'
actionpack (4.0.2) lib/action_view/helpers/rendering_helper.rb:24:in `render'
app/views/admin/application/index.html.erb:14:in `block in _app_views_admin_application_index_html_erb__1045387382_50813388'
app/views/admin/application/index.html.erb:12:in `each'
app/views/admin/application/index.html.erb:12:in `_app_views_admin_application_index_html_erb__1045387382_50813388'
actionpack (4.0.2) lib/action_view/template.rb:143:in `block in render'
activesupport (4.0.2) lib/active_support/notifications.rb:161:in `instrument'
actionpack (4.0.2) lib/action_view/template.rb:141:in `render'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:49:in `block (2 levels) in render_template'
actionpack (4.0.2) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.2) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:48:in `block in render_template'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:56:in `render_with_layout'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:47:in `render_template'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:17:in `render'
actionpack (4.0.2) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionpack (4.0.2) lib/action_view/renderer/renderer.rb:23:in `render'
actionpack (4.0.2) lib/abstract_controller/rendering.rb:127:in `_render_template'
actionpack (4.0.2) lib/action_controller/metal/streaming.rb:219:in `_render_template'
actionpack (4.0.2) lib/abstract_controller/rendering.rb:120:in `render_to_body'
actionpack (4.0.2) lib/action_controller/metal/rendering.rb:33:in `render_to_body'
actionpack (4.0.2) lib/action_controller/metal/renderers.rb:26:in `render_to_body'
actionpack (4.0.2) lib/abstract_controller/rendering.rb:97:in `render'
actionpack (4.0.2) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.0.2) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
activesupport (4.0.2) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.0.2) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:40:in `render'
actionpack (4.0.2) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.0.2) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (4.0.2) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.0.2) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.0.2) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (4.0.2) lib/active_support/callbacks.rb:433:in `_run__894777034__process_action__callbacks'
activesupport (4.0.2) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.2) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (4.0.2) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.0.2) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (4.0.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.0.2) lib/abstract_controller/base.rb:136:in `process'
actionpack (4.0.2) lib/abstract_controller/rendering.rb:44:in `process'
actionpack (4.0.2) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.0.2) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.0.2) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:680:in `call'
lib/error_alert.rb:14:in `call'
rack-cors (0.2.9) lib/rack/cors.rb:54: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 `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/flash.rb:241: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'
actionpack (4.0.2) lib/action_dispatch/middleware/cookies.rb:486:in `call'
activerecord (4.0.2) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.2) lib/active_record/migration.rb:369:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.2) lib/active_support/callbacks.rb:373:in `_run__692376707__call__callbacks'
activesupport (4.0.2) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.2) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.2) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.2) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.0.2) lib/rails/engine.rb:511:in `call'
railties (4.0.2) lib/rails/application.rb:97:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
thin (1.6.1) lib/thin/connection.rb:82:in `block in pre_process'
thin (1.6.1) lib/thin/connection.rb:80:in `catch'
thin (1.6.1) lib/thin/connection.rb:80:in `pre_process'
thin (1.6.1) lib/thin/connection.rb:55:in `process'
thin (1.6.1) lib/thin/connection.rb:41:in `receive_data'
eventmachine-1.0.3-x86 (mingw32) lib/eventmachine.rb:187:in `run_machine'
eventmachine-1.0.3-x86 (mingw32) lib/eventmachine.rb:187:in `run'
thin (1.6.1) lib/thin/backends/base.rb:73:in `start'
thin (1.6.1) 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.0.2) lib/rails/commands/server.rb:84:in `start'
railties (4.0.2) lib/rails/commands.rb:76:in `block in <top (required)>'
railties (4.0.2) lib/rails/commands.rb:71:in `tap'
railties (4.0.2) lib/rails/commands.rb:71:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
I think it does judging from this snippet from https://github.com/josevalim/inherited_resources
class ProjectsController < InheritedResources::Base
protected
def collection
#projects ||= end_of_association_chain.paginate(:page => params[:page])
end
end
So for Kaminari you might do this:
class ProjectsController < InheritedResources::Base
protected
def collection
#projects ||= end_of_association_chain.page params[:page]
end
end
Although I haven't had a chance to try it yet.
I have tested this and it works perfectly.

LoadError in Users::OmniauthCallbacksController#facebook - Rails 4

well, I am trying to code a system that uses facebook login. When I click on the facebook link it goes to facebook page for authentication and on the callback show me this error: Unable to autoload constant Users::OmniauthCallbacksController, expected path/app/controllers/users/omniauth_callbacks_controller.rb to define it.
I am using devise gem, omniauth gem, ruby 2 and rails 4.
My user_controller.rb
class User::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
#user = User.find_for_facebook_oauth(request.env['omniauth.auth'], current_user)
if #user.persisted?
sign_in_and_redirect #user, :event => :authentication #this will throw if #user is not activated
set_flash_message(:notice, :success, :kind => 'Facebook') if is_navigational_format?
else
session['devise.facebook_data'] = request.env['omniauth.auth']
redirect_to new_user_registration_url
end
end
end
My user.rb
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :omniauthable
def self.find_for_facebook_oauth(auth, signed_in_resource = nil)
user = User.where(:provider => auth.provider, :uid => auth.uid).first
if user
return user
else
registered_user = User.where(:email => auth.info.email).first
if registered_user
return registered_user
else
user = User.create(name:auth.extra.raw_info.name,
provider:auth.provider,
uid:auth.uid,
email:auth.info.email,
password:Devise.friendly_token[0,20],
)
end
end
end
end
On routes.rb I have this line:
devise_for :users, :controllers => { :omniauth_callbacks => 'users/omniauth_callbacks' }
The Full Trace is this:
activesupport (4.0.0) lib/active_support/dependencies.rb:463:in `load_missing_constant'
activesupport (4.0.0) lib/active_support/dependencies.rb:183:in `const_missing'
activesupport (4.0.0) lib/active_support/inflector/methods.rb:228:in `const_get'
activesupport (4.0.0) lib/active_support/inflector/methods.rb:228:in `block in constantize'
activesupport (4.0.0) lib/active_support/inflector/methods.rb:224:in `each'
activesupport (4.0.0) lib/active_support/inflector/methods.rb:224:in `inject'
activesupport (4.0.0) lib/active_support/inflector/methods.rb:224:in `constantize'
activesupport (4.0.0) lib/active_support/dependencies.rb:534:in `get'
activesupport (4.0.0) lib/active_support/dependencies.rb:565:in `constantize'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:76:in `controller_reference'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:66:in `controller'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:44:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/mapper.rb:44:in `call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in `call'
omniauth (1.1.4) lib/omniauth/strategy.rb:184:in `call!'
omniauth (1.1.4) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.1.4) lib/omniauth/strategy.rb:184:in `call!'
omniauth (1.1.4) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.1.4) lib/omniauth/strategy.rb:401:in `call_app!'
omniauth (1.1.4) lib/omniauth/strategy.rb:363:in `callback_phase'
omniauth-oauth2 (1.1.1) lib/omniauth/strategies/oauth2.rb:77:in `callback_phase'
omniauth (1.1.4) lib/omniauth/strategy.rb:226:in `callback_call'
omniauth (1.1.4) lib/omniauth/strategy.rb:182:in `call!'
omniauth (1.1.4) lib/omniauth/strategy.rb:164: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 `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/flash.rb:241: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'
actionpack (4.0.0) lib/action_dispatch/middleware/cookies.rb:486:in `call'
activerecord (4.0.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.0) lib/active_record/migration.rb:369:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.0) lib/active_support/callbacks.rb:373:in `_run__878755641__call__callbacks'
activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call'
railties (4.0.0) lib/rails/engine.rb:511:in `call'
railties (4.0.0) lib/rails/application.rb:97:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
C:/Development/Ruby200/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
C:/Development/Ruby200/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
C:/Development/Ruby200/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
So that's my problem I hope someone can help me.
EDIT: rather than what I implied to, my callbacks controller is called omniauth_callbacks_controller.rb.
1. As sevenseacat suggested I changed the reference from users to user on my route file, but the problem still happened.
2. As *uno_ordinary* suggested I added :omniauth_providers => :facebook on my model but after that I received a new error when starting the server:
=> Booting WEBrick
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
C:3:in `rescue in execute_if_updated': Rails::Application::RoutesReloader#execute_if_updated delegated to updater.execute_if_updated, but updater is nil: #<Rails::Application::RoutesReloader:0x4375db8 #paths=["C:/Users/Diogo de Lima/Documents/Development/Ruby on Rails/Rhodnius/config/routes.rb"], #route_sets=[#<ActionDispatch::Routing::RouteSet:0x449da98>]> (RuntimeError)
from C:131071:in `execute_if_updated'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
from C:/Development/Ruby200/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
from C:/Development/Ruby200/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
from C:/Development/Ruby200/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
from C:/Development/Ruby200/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
from C:/Development/Ruby200/lib/ruby/2.0.0/tsort.rb:180:in `each'
from C:/Development/Ruby200/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
from C:/Development/Ruby200/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
from C:/Users/Diogo de Lima/Documents/Development/Ruby on Rails/Rhodnius/config/environment.rb:5:in `<top (required)>'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from C:/Users/Diogo de Lima/Documents/Development/Ruby on Rails/Rhodnius/config.ru:3:in `block in <main>'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from C:/Users/Diogo de Lima/Documents/Development/Ruby on Rails/Rhodnius/config.ru:in `new'
from C:/Users/Diogo de Lima/Documents/Development/Ruby on Rails/Rhodnius/config.ru:in `<main>'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/server.rb:48:in `app'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/server.rb:75:in `start'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:78:in `block in <top (required)>'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
from C:/Development/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
If your callbacks controller is in a file called user_controller.rb (as your post implies), this is incorrect.
To follow Rails' naming conventions, it needs to be in app/controllers/users/omniauth_callbacks_controller.rb (as the error tells you).
You also have a problem with namespacing - your route for the callbacks controller refers to users (plural), while your controller namespace is User (singular).
Try to add to User model the following:
:omniauthable, :omniauth_providers => [:facebook]

undefined method `each' for String when using https

In my application staging environment there is an error when I try to access a page over https, the webpage is correctly working with http. The error I get is :
undefined method `each' for #<String:0x00000009371f28>
The place where it fails is on in th gem rack on the line:
body.each { |part| parts << part }
in
def digest_body(body)
parts = []
body.each { |part| parts << part }
string_body = parts.join
digest = Digest::MD5.hexdigest(string_body) unless string_body.empty?
[digest, parts]
end
It seems that he can't handle the body that is passed. I inspected the body and it is a string with all the html code of my page in it. The data type of this parameter should be an array.
"<!DOCTYPE html>\n<html class='no-js' lang='fr' xml:lang='fr'>\n<head>\n<meta charset='utf-8'>\n<meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'>\n<meta content='width=device-width' name='viewport'>\n<title>Bienvenue sur Zurban Culture | Admin Panel | Zurban Culture</title>\n<meta content=\"authenticity_token\" name=\"csrf-param\" />\n<meta content=\"fEVrJPyUwdf4FZ2GSWW/p01SrByXlJpq+xSbAXOkxBg=\" name=\"csrf-token\" />\n<!--[if lt IE 9]>\n<script src='http://html5shim.googlecode.com/svn/trunk/html5.js' type='text/javascript'></script>\n<![endif]-->\n<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js\" type=\"text/javascript\"></script>\n<link href=\"/assets/admin/admin-6033541466a41863e188a9fa9e0ea9bd.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<link href=\"/assets/admin/print-088f5bc50dba980c42676157c724ed0a.css\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />\n\n<script src='https://www.google.com/jsapi' type='text/javascript'></script>\n\n<link href='/favicon.ico' rel='shortcut icon'>\n</head>\n<body data-offset='50' data-spy='scroll' id='admin_show'>\n<h1 class='hidden print'>\nZurban Culture\n</h1>\n<div class='navbar navbar-fixed-top noPrint'>\n<div class='navbar-inner'>\n<div class='container-fluid'>\n<a class='btn btn-navbar' data-target='.nav-collapse' data-toggle='collapse'>\n<span class='icon-bar'></span>\n<span class='icon-bar'></span>\n<span class='icon-bar'></span>\n</a>\n<a class='brand' href='/admin'>Zurban Culture</a>\n<div class='nav-collapse'>\n<ul class='nav' id='tabbedInterface'>\n<li class=\"dropdown\">Produits<b class=\"caret\"></b><ul class='dropdown-menu'>\n<li>Tous produits (4064)</li>\n<li>Brouillons (156)</li>\n<li>Effacés (274)</li>\n<li>Bons</li>\n<li>Familles (24)</li>\n<li>Maintenance</li>\n</ul>\n</li><li class=\"brands_tab\">Marques</li>\n<li class=\"dropdown\">Ventes & Marketing<b class=\"caret\"></b><ul class='dropdown-menu'>\n<li>En vente (3905)</li>\n<li>Brouillons (142)</li>\n<li>Planning (0)</li>\n<li><span class=\"translation_missing\" title=\"translation missing: fr.admin.menu.sales.planned\">Planned</span></li>\n<li>Codes promotionnels (27)</li>\n<li>Page d'accueil</li>\n<li>Collections</li>\n<li>Chèques cadeaux</li>\n<li>Chèques</li>\n</ul>\n</li><li class=\"dropdown\">Commandes<b class=\"caret\"></b><ul class='dropdown-menu'>\n<li>En attente (0)</li>\n<li>A vérifier (3)</li>\n<li>Payées (7)</li>\n<li>Traitement (0)</li>\n<li>Envoyées (307)</li>\n<li>Complètée (9205)</li>\n<li>Indisponible (1)</li>\n<li>Annulées (8736)</li>\n<li>Fraudes (12)</li>\n<li>Tentatives de paiements</li>\n</ul>\n</li><li class=\"dropdown\">Retours<b class=\"caret\"></b><ul class='dropdown-menu'>\n<li>En attente (77)</li>\n<li>Réceptionné (23)</li>\n<li>Remboursé (1115)</li>\n<li>Procédure annulée (4)</li>\n</ul>\n</li><li class=\"dropdown\">Avis <b class=\"caret\"></b><ul class='dropdown-menu'>\n<li>À approuver (0)</li>\n<li>Approuvés (3)</li>\n<li>Refusés (0)</li>\n<li>Effacés (0)</li>\n</ul>\n</li><li class=\"dropdown\">Utilisateurs<b class=\"caret\"></b><ul class='dropdown-menu'>\n<li>Utilisateurs</li>\n<li>Utilisateurs effacés</li>\n<li>Invitations</li>\n</ul>\n</li><li class=\"help_sections_tab\">Sections d'aide</li>\n<li class=\"dropdown\"><img alt=\"Icon_stats\" src=\"/assets/admin/icon_stats-3905dbfb6e4ba900e54d7c49d67f5c49.png\" /><b class=\"caret\"></b><ul class='dropdown-menu'>\n<li>\n<span class=\"translation_missing\" title=\"translation missing: fr.admin.submenu.overview\">Overview</span>\n</li>\n<li>\n<span class=\"translation_missing\" title=\"translation missing: fr.admin.submenu.products\">Products</span>\n</li>\n<li>\n<span class=\"translation_missing\" title=\"translation missing: fr.admin.submenu.orders\">Orders</span>\n</li>\n<li>\n<span class=\"translation_missing\" title=\"translation missing: fr.admin.submenu.returns\">Returns</span>\n</li>\n<li>\n<span class=\"translation_missing\" title=\"translation missing: fr.admin.submenu.users\">Users</span>\n</li>\n<li>\n<span class=\"translation_missing\" title=\"translation missing: fr.admin.submenu.sales_report\">Sales Report</span>\n</li>\n<li>\n<span class=\"translation_missing\" title=\"translation missing: fr.admin.submenu.stock_report\">Stock Report</span>\n</li>\n<li>\n<span class=\"translation_missing\" title=\"translation missing: fr.admin.submenu.purchase_report\">Purchase Report</span>\n</li>\n<li>\n<span class=\"translation_missing\" title=\"translation missing: fr.admin.submenu.sales_history\">Sales History</span>\n</li>\n<li>\n<span class=\"translation_missing\" title=\"translation missing: fr.admin.submenu.favorites\">Favorites</span>\n</li>\n</ul>\n</li></ul>\n\n<ul class='nav pull-right'>\n<li class='searchbox'>\n<form accept-charset=\"UTF-8\" action=\"/admin/search\" class=\"navbar-search pull-right\" method=\"get\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /></div>\n<input class=\"search-query span2\" id=\"query\" name=\"query\" size=\"20\" type=\"text\" value=\"Rechercher\" />\n\n</form>\n\n</li>\n<li class='dropdown'>\n<a class='dropdown-toggle' data-toggle='dropdown' href='#'>\n<i class='icon-user icon-white'></i>\n</a>\n<ul class='dropdown-menu'>\n<li>\nZurban Culture\n</li>\n<li>\nDéconnexion\n</li>\n</ul>\n</li>\n</ul>\n\n</div>\n</div>\n</div>\n</div>\n<div class='container-fluid noPrint'>\n<div class='subnav'>\n<ul class='nav nav-pills'>\n<li class=\"active\">Statistique rapides</li>\n<li>Logs</li>\n</ul>\n\n</div>\n<div class='notices_wrapper noPrint'>\n<div class='row-fluid'>\n<div class='span12'>\n\n</div>\n</div>\n</div>\n</div>\n<div class='container-fluid'>\n<div class='row-fluid'>\n<div class='span12'>\n<div class=\"page-header\">\n <h1>Bienvenue sur Zurban Culture</h1> \n</div>\n\n\n <form accept-charset=\"UTF-8\" action=\"https://beta.jeansattitude.fr/admin\" class=\"well\" method=\"get\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /></div>\n <input class=\"datepicker onChangeSubmit\" id=\"start_date\" length=\"8\" name=\"start_date\" placeholder=\"Start Date\" type=\"text\" value=\"2013-04-01\" />\n <input class=\"datepicker onChangeSubmit\" id=\"end_date\" length=\"8\" name=\"end_date\" placeholder=\"End Date\" type=\"text\" value=\"2013-04-23\" />\n <input type=\"submit\" class=\"btn\">\n </form>\n <div class=\"row-fluid\">\n <div class=\"section dashboard span6\" id=\"orders_section\">\n <div class=\"well\">\n <h2 class=\"sectionHeader\">Montant des ventes cumulés</h2>\n <div id=\"ordersChart\" class=\"graph\" style=\"width: 95%; height: 300px; margin: 0; padding: 0\"></div>\n </div>\n </div>\n <div class=\"section dashboard span6\" id=\"revenue_section\">\n <div class=\"well\">\n <h2 class=\"sectionHeader\">Montant des ventes</h2>\n <div id=\"revenueChart\" class=\"graph\" style=\"width: 95%; height: 300px; margin: 0; padding: 0\"></div>\n </div>\n </div>\n </div>\n\n <div class=\"row-fluid\">\n <div class=\"section dashboard span6\" id=\"orders_shipped_section\">\n <div class=\"well\">\n <h2 class=\"sectionHeader\">Commandes Expédiées</h2>\n <div id=\"shippedOrdersChart\" class=\"graph\" style=\"width: 95%; height: 300px; margin: 0; padding: 0\"></div>\n </div>\n </div>\n\n <div class=\"section dashboard span6\" id=\"users_section\">\n <div class=\"well\">\n <h2 class=\"sectionHeader\">Nouveaux utilisateurs confirmés</h2>\n <div id=\"usersChart\" class=\"graph\" style=\"width: 95%; height: 300px; margin: 0; padding: 0\"></div>\n </div>\n </div>\n </div>\n\n\n <div id=\"revenueChart\"></div>\n<script type=\"text/javascript\" src=\"http://www.google.com/jsapi\"></script>\n<script type=\"text/javascript\">\nvar rgviz_revenueChart = null;\nvar rgviz_revenueChart_data = null;\nfunction rgviz_draw_revenueChart() {\n var query = new google.visualization.Query('http://stats.zurbanculture.fr/orders/datasource');\n var q = 'select toDate(`paid_at`), `old_members`, `new_members` where ((`state` = \"paid\" or `state` = \"processing\" or `state` = \"shipped\" or `state` = \"completed\") and `paid_at` >= \"2013-04-01\" and `paid_at` <= \"2013-04-24\") group by toDate(`paid_at`) order by toDate(`paid_at`) asc label toDate(`paid_at`) \\'Date\\', `old_members` \\'Ventes Anciens Utilisateurs\\', `new_members` \\'Ventes Nouveaux Utilisateurs\\'';\n query.setQuery(q);\n query.send(function(response) {\n rgviz_revenueChart = new google.visualization.ColumnChart(document.getElementById('revenueChart'));\n rgviz_revenueChart_data = response.getDataTable();\n rgviz_revenueChart_options = {\"is3D\":true,\"width\":\"100%\",\"height\":\"80%\",\"legend\":{\"position\":\"bottom\",\"textStyle\":{\"fontSize\":12}},\"chartArea\":{\"left\":70,\"top\":30,\"width\":\"85%\",\"height\":\"75%\"},\"isStacked\":true};\n rgviz_revenueChart.draw(rgviz_revenueChart_data, rgviz_revenueChart_options);\n});\n}\ngoogle.load(\"visualization\", \"1\", {'packages':['corechart']});\ngoogle.setOnLoadCallback(rgviz_draw_revenueChart);\n</script>\n\n\n <div id=\"ordersChart\"></div>\n<script type=\"text/javascript\">\nvar rgviz_ordersChart = null;\nvar rgviz_ordersChart_data = null;\nfunction rgviz_draw_ordersChart() {\n var query = new google.visualization.Query('http://stats.zurbanculture.fr/orders/datasource');\n var q = 'select toDate(`paid_at`), sum(`total`) where ((`state` = \"paid\" or `state` = \"processing\" or `state` = \"shipped\" or `state` = \"completed\") and `paid_at` >= \"2013-04-01\" and `paid_at` <= \"2013-04-24\") group by toDate(`paid_at`) order by toDate(`paid_at`) asc label toDate(`paid_at`) \\'Date\\', sum(`total`) \\'Montant Ventes\\'';\n query.setQuery(q);\n query.send(function(response) {\n rgviz_ordersChart = new google.visualization.ColumnChart(document.getElementById('ordersChart'));\n rgviz_ordersChart_data = response.getDataTable();\n rgviz_ordersChart_options = {\"is3D\":true,\"width\":\"100%\",\"height\":\"80%\",\"legend\":\"none\",\"chartArea\":{\"left\":70,\"top\":30,\"width\":\"85%\",\"height\":\"75%\"}};\n rgviz_ordersChart.draw(rgviz_ordersChart_data, rgviz_ordersChart_options);\n});\n}\ngoogle.setOnLoadCallback(rgviz_draw_ordersChart);\n</script>\n\n <div id=\"shippedOrdersChart\"></div>\n<script type=\"text/javascript\">\nvar rgviz_shippedOrdersChart = null;\nvar rgviz_shippedOrdersChart_data = null;\nfunction rgviz_draw_shippedOrdersChart() {\n var query = new google.visualization.Query('http://stats.zurbanculture.fr/orders/datasource');\n var q = 'select toDate(`shipped_at`), count(`id`) where ((`state` = \"paid\" or `state` = \"processing\" or `state` = \"shipped\" or `state` = \"completed\") and `shipped_at` >= \"2013-04-01\" and `paid_at` <= \"2013-04-24\") group by toDate(`shipped_at`) order by toDate(`shipped_at`) asc label toDate(`shipped_at`) \\'Date\\', count(`id`) \\'Commandes Expédiées\\'';\n query.setQuery(q);\n query.send(function(response) {\n rgviz_shippedOrdersChart = new google.visualization.AreaChart(document.getElementById('shippedOrdersChart'));\n rgviz_shippedOrdersChart_data = response.getDataTable();\n rgviz_shippedOrdersChart_options = {\"is3D\":true,\"width\":\"100%\",\"height\":\"80%\",\"legend\":\"none\",\"chartArea\":{\"left\":70,\"top\":30,\"width\":\"85%\",\"height\":\"75%\"}};\n rgviz_shippedOrdersChart.draw(rgviz_shippedOrdersChart_data, rgviz_shippedOrdersChart_options);\n});\n}\ngoogle.setOnLoadCallback(rgviz_draw_shippedOrdersChart);\n</script>\n\n <div id=\"usersChart\"></div>\n<script type=\"text/javascript\">\nvar rgviz_usersChart = null;\nvar rgviz_usersChart_data = null;\nfunction rgviz_draw_usersChart() {\n var query = new google.visualization.Query('http://stats.zurbanculture.fr/users/datasource');\n var q = 'select concat(month(`created_at`), \" \", year(`created_at`)), `seo`, `organique` where (`created_at` >= \"2012-04-23\" and `created_at` <= \"2013-04-24\" and `confirmed` = 1) group by concat(month(`created_at`), \" \", year(`created_at`)) order by `created_at` asc label concat(month(`created_at`), \" \", year(`created_at`)) \\'Month\\', `seo` \\'SEO\\', `organique` \\'Organique\\'';\n query.setQuery(q);\n query.send(function(response) {\n rgviz_usersChart = new google.visualization.LineChart(document.getElementById('usersChart'));\n rgviz_usersChart_data = response.getDataTable();\n rgviz_usersChart_options = {\"is3D\":true,\"width\":\"100%\",\"height\":\"80%\",\"legend\":{\"position\":\"bottom\",\"textStyle\":{\"fontSize\":12}},\"chartArea\":{\"left\":70,\"top\":30,\"width\":\"85%\",\"height\":\"75%\"}};\n rgviz_usersChart.draw(rgviz_usersChart_data, rgviz_usersChart_options);\n});\n}\ngoogle.setOnLoadCallback(rgviz_draw_usersChart);\n</script>\n\n\n</div>\n</div>\n<footer class='footer'>\n<p>Zurban Culture v2.0 - Rails 3.2.13 (staging) / Ruby 1.9.3 patchlevel 327 2012-11-10 - /srv/www/jeansattitude/releases/20130423082652</p>\n</footer>\n</div>\n<script src=\"/assets/admin-ac2e83dde06736c3279cc5c973afd46a.js\" type=\"text/javascript\"></script>\n\n</body>\n</html>\n"
Someone has an idea why the request fails and the body is not containing and array like it needs to be? Here you see my traceroute, it isn't clear for me what cause the problem because I don't see any trace of my application in it and I don't pass anything to this function from my application.
NoMethodError (undefined method `each' for #<String:0x00000009371f28>):
rack (1.4.5) lib/rack/etag.rb:59:in `digest_body'
rack (1.4.5) lib/rack/etag.rb:26:in `call'
rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.13) 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.13) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.13) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `_run__965187821369700966__call__4271865895200548975__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
airbrake (3.1.11) lib/airbrake/rails/middleware.rb:13:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.13) 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.13) 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.13) lib/action_dispatch/middleware/static.rb:63:in `call'
rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
airbrake (3.1.11) lib/airbrake/user_informer.rb:16:in `_call'
airbrake (3.1.11) lib/airbrake/user_informer.rb:12:in `call'
railties (3.2.13) lib/rails/engine.rb:479:in `call'
railties (3.2.13) lib/rails/application.rb:223:in `call'
railties (3.2.13) lib/rails/railtie/configurable.rb:30:in `method_missing'
passenger (3.0.19) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
passenger (3.0.19) lib/phusion_passenger/abstract_request_handler.rb:516:in `accept_and_process_next_request'
passenger (3.0.19) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
passenger (3.0.19) lib/phusion_passenger/rack/application_spawner.rb:206:in `start_request_handler'
passenger (3.0.19) lib/phusion_passenger/rack/application_spawner.rb:171:in `block in handle_spawn_application'
passenger (3.0.19) lib/phusion_passenger/utils.rb:470:in `safe_fork'
passenger (3.0.19) lib/phusion_passenger/rack/application_spawner.rb:166:in `handle_spawn_application'
passenger (3.0.19) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.19) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.19) lib/phusion_passenger/abstract_server.rb:180:in `start'
passenger (3.0.19) lib/phusion_passenger/rack/application_spawner.rb:129:in `start'
passenger (3.0.19) lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application'
passenger (3.0.19) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
passenger (3.0.19) lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application'
passenger (3.0.19) lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
<internal:prelude>:10:in `synchronize'
passenger (3.0.19) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
passenger (3.0.19) lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
passenger (3.0.19) lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
passenger (3.0.19) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
passenger (3.0.19) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.19) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.19) helper-scripts/passenger-spawn-server:99:in `<main>'
See also my issue I opened on the rack gem, but it seems not a issue from them. https://github.com/rack/rack/issues/548
SOLUTION:
This happened because of a custom middleware that was returning the body as a string, I wrapped this body in an array and problem was solved! Thanks for the help!
You say:
I inspected the body and it is a string with all the html code of my page in it. The data type of this parameter should be an array.
Where is the body parameter coming from? What do you expect the elements of this array to be? It seems like this may be what you want:
def digest_body(body)
parts = body.split("\n")
string_body = parts.join
digest = Digest::MD5.hexdigest(string_body) unless string_body.empty?
[digest, parts]
end

How to make this work in Rails 3?

I am updating a Rails project and found a piece of code that doesn't work in Rails 3 and Ruby 1.9.2 (it did in Rails 2.3 and Ruby 1.8.7) and looks quite messy anyway!
def speech_box(title, options = {}, &block)
block_to_partial 'layouts/speech_box', options.merge(:title => title), &block
end
def block_to_partial(partial_name, options = {}, &block)
options.merge!(:body => capture(&block))
concat(render(:partial => partial_name, :locals => options), block.binding)
end
I am getting the following error when I call:
<% speech_box("hello") do %>
<p>lorem ipsum</p>
<% end %>
wrong number of arguments (2 for 1)
How come this doesn't work in Rails 3?
As requested below, here is the trace:
actionpack (3.1.0) lib/action_view/helpers/text_helper.rb:51:in `concat'
app/helpers/application_helper.rb:277:in `block_to_partial'
app/helpers/application_helper.rb:272:in `speech_box'
app/views/talks/new.html.erb:46:in `_app_views_talks_new_html_erb__3484685084088947386_2193902320'
actionpack (3.1.0) lib/action_view/template.rb:144:in `block in render' activesupport (3.1.0)
lib/active_support/notifications.rb:55:in `instrument' actionpack (3.1.0)
lib/action_view/template.rb:142:in `render' actionpack (3.1.0)
lib/action_view/renderer/template_renderer.rb:40:in `block (2 levels) in render_template' actionpack (3.1.0)
lib/action_view/renderer/abstract_renderer.rb:33:in `block in instrument' activesupport (3.1.0)
lib/active_support/notifications.rb:53:in `block in instrument' activesupport (3.1.0)
lib/active_support/notifications/instrumenter.rb:21:in `instrument' activesupport (3.1.0)
lib/active_support/notifications.rb:53:in `instrument' actionpack (3.1.0)
lib/action_view/renderer/abstract_renderer.rb:33:in `instrument' actionpack (3.1.0)
lib/action_view/renderer/template_renderer.rb:39:in `block in render_template' actionpack (3.1.0)
lib/action_view/renderer/template_renderer.rb:47:in `render_with_layout' actionpack (3.1.0)
lib/action_view/renderer/template_renderer.rb:38:in `render_template' actionpack (3.1.0)
lib/action_view/renderer/template_renderer.rb:12:in `block in render' actionpack (3.1.0)
lib/action_view/renderer/abstract_renderer.rb:22:in `wrap_formats' actionpack (3.1.0)
lib/action_view/renderer/template_renderer.rb:9:in `render' actionpack (3.1.0)
lib/action_view/renderer/renderer.rb:36:in `render_template' actionpack (3.1.0)
lib/action_view/renderer/renderer.rb:17:in `render' actionpack (3.1.0)
lib/abstract_controller/rendering.rb:120:in `_render_template' actionpack (3.1.0)
lib/action_controller/metal/streaming.rb:250:in `_render_template' actionpack (3.1.0)
lib/abstract_controller/rendering.rb:114:in `render_to_body' actionpack (3.1.0)
lib/action_controller/metal/renderers.rb:30:in `render_to_body' actionpack (3.1.0)
lib/action_controller/metal/compatibility.rb:43:in `render_to_body' actionpack (3.1.0)
lib/abstract_controller/rendering.rb:99:in `render' actionpack (3.1.0)
lib/action_controller/metal/rendering.rb:16:in `render' actionpack (3.1.0)
lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render' activesupport (3.1.0)
lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
.............
concat is gone. Simply remove concat and make sure to call speech_box using <%= instead of <%.
def block_to_partial(partial_name, options = {}, &block)
options.merge!(:body => capture(&block))
render(:partial => partial_name, :locals => options)
end
<%= speech_box("hello") do %>
<p>lorem ipsum</p>
<% end %>

Resources