I have the following code:
# file app/models/admin/categoria.rb
class Admin::Categoria < ActiveRecord::Base
has_many :posts
end
# file app/models/admin/post.rb
class Admin::Post < ActiveRecord::Base
belongs_to :categoria, foreign_key: "categoria_id"
end
I am trying to display the title (titulo) from Categorias table like the following code:
# file app/views/admin/posts/index.html.erb
<% #posts.each do |post| %>
<tr>
<td><%= post.titulo %></td>
<td><%= post.slug %></td>
<td><%= post.created_at %></td>
<td><%= post.categoria_id %></td>
</tr>
<% end %>
It shows the number of ID. If I try:
<td><%= post.categoria.titulo %></td>
I get the error "undefined method `categoria'". Here is the stacktrace:
activemodel (4.1.0) lib/active_model/attribute_methods.rb:435:in `method_missing'
activerecord (4.1.0) lib/active_record/attribute_methods.rb:206:in `method_missing'
app/views/admin/posts/index.html.erb:20:in `block in _app_views_admin_posts_index_html_erb___3127847778944241957_70050289571840'
activerecord (4.1.0) lib/active_record/relation/delegation.rb:46:in `each'
activerecord (4.1.0) lib/active_record/relation/delegation.rb:46:in `each'
app/views/admin/posts/index.html.erb:15:in `_app_views_admin_posts_index_html_erb___3127847778944241957_70050289571840'
actionview (4.1.0) lib/action_view/template.rb:145:in `block in render'
activesupport (4.1.0) lib/active_support/notifications.rb:161:in `instrument'
actionview (4.1.0) lib/action_view/template.rb:339:in `instrument'
actionview (4.1.0) lib/action_view/template.rb:143:in `render'
actionview (4.1.0) lib/action_view/renderer/template_renderer.rb:55:in `block (2 levels) in render_template'
actionview (4.1.0) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (4.1.0) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.0) lib/active_support/notifications.rb:159:in `instrument'
actionview (4.1.0) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionview (4.1.0) lib/action_view/renderer/template_renderer.rb:54:in `block in render_template'
actionview (4.1.0) lib/action_view/renderer/template_renderer.rb:62:in `render_with_layout'
actionview (4.1.0) lib/action_view/renderer/template_renderer.rb:53:in `render_template'
actionview (4.1.0) lib/action_view/renderer/template_renderer.rb:17:in `render'
actionview (4.1.0) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (4.1.0) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (4.1.0) lib/action_view/rendering.rb:99:in `_render_template'
actionpack (4.1.0) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.1.0) lib/action_view/rendering.rb:82:in `render_to_body'
actionpack (4.1.0) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.1.0) lib/action_controller/metal/renderers.rb:32:in `render_to_body'
actionpack (4.1.0) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.1.0) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.1.0) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.1.0) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/usr/local/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
activesupport (4.1.0) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.1.0) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.1.0) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.1.0) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.1.0) lib/action_controller/metal/instrumentation.rb:40:in `render'
actionpack (4.1.0) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.1.0) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (4.1.0) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.0) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.0) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.0) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.0) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.0) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.0) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.0) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.0) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.0) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.1.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.0) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.1.0) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.0) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.0) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:676: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.1.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.0) lib/action_dispatch/middleware/flash.rb:254: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.1.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
activerecord (4.1.0) lib/active_record/migration.rb:380:in `call'
actionpack (4.1.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.0) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.0) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.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.1.0) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.0) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.0) lib/rails/engine.rb:514:in `call'
railties (4.1.0) lib/rails/application.rb:144: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'
/usr/local/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/usr/local/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/usr/local/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
How can I display "titulo" from Categorias table?
Change your model definitions as below:
# file app/models/admin/categoria.rb
class Admin::Categoria < ActiveRecord::Base
has_many :posts, class_name: "Admin::Post"
end
# file app/models/admin/post.rb
class Admin::Post < ActiveRecord::Base
belongs_to :categoria, class_name: "Admin::Categoria", foreign_key: "categoria_id"
end
As your models are namespaced within Admin module. I have added class_name option in the associations.
You need to do categoria belongs_to :post and post has_one :categoria
Also, you don't need to declare the foreign key. Rails will automatically look for the column categoria_id in posts if you declare the relationship.
Related
I am worried about this error am having called Unknown key: deposit. Though I tried to remove the constants which is not used in this snippet even though I cant do that, but it still complained about sum method in the view.
All am trying to do is to have array map I could use in the view to show my results.
attribution_helper.rb
module AttributionHelper
def statistics(events=nil)
case events
when Attribution::PARTNER_DASHBOARD_EVENTS
Attribution::PARTNER_DASHBOARD_EVENTS.map { |event| [ event, (Attribution.attribution_count[event.to_s] || 0), Attribution.onbaording_attribution_stats["#{event}"] || 0] }
when Attribution::PARTNER_BILLABLE_EVENTS
array_result = Attribution::PARTNER_BILLABLE_EVENTS.map { |event| [ event, (Attribution.attribution_count[event.to_s] || 0), Attribution.billable_attribution_stats["#{event}"] || 0] }
["total", array_result.sum(&:second), array_result.sum(&:third)]
else
Attribution::EVENTS.map { |event| [ event, (Attribution.attribution_count[event.to_s] || 0), Attribution.all_attribution_stats["#{event}"] || 0] }
end
end
end
attribution.rb model
include AttributionHelper
VISIT = "visit"
SIGN_UP = "sign_up"
DEPOSIT = "deposit"
WITHDRAW = "withdraw"
ORDER_DONE = "order_done"
ORDER_SUBMIT = "order_submit"
KYC_VERIFIED = "kyc_verified"
EVENTS = [VISIT, SIGN_UP, KYC_VERIFIED, DEPOSIT, WITHDRAW, ORDER_SUBMIT, ORDER_DONE]
PARTNER_DASHBOARD_EVENTS = [VISIT, SIGN_UP]
PARTNER_BILLABLE_EVENTS = [ORDER_DONE, WITHDRAW]
scope :grouped_attribution, -> { self.group(:event) }
scope :attribution_count, -> { grouped_attribution.count }
scope :all_attribution_stats, -> { grouped_attribution.sum(:bonus_amount) }
scope :onbaording_attribution_stats, -> { grouped_attribution.where("event = ? OR event = ?", Attribution::VISIT, Attribution::SIGN_UP).sum(:bonus_amount) }
scope :billable_attribution_stats, -> { grouped_attribution.where("event = ? OR event = ?", Attribution::ORDER_DONE, Attribution::WITHDRAW).sum(:bonus_amount) }
views
h2.text-center
code class='text-info' = #price_widget.attribution_channel.statistics(Attribution::PARTNER_DASHBOARD_EVENTS + Attribution::PARTNER_BILLABLE_EVENTS).sum(&:third).to_s(:delimited)
These are the result of the scopes:
grouped_attribution.count
(0.5ms) SELECT COUNT(*) AS count_all, event AS event FROM `attributions` GROUP BY event
=> {“deposit”=>2, “order_done”=>14, “sign_up”=>10, “visit”=>46, “withdraw”=>2}
grouped_attribution.sum(:bonus_amount)
(0.6ms) SELECT SUM(`attributions`.`bonus_amount`) AS sum_bonus_amount, event AS event FROM `attributions` GROUP BY event
=> {“deposit”=>10, “order_done”=>600, “sign_up”=>10000, “visit”=>15000, “withdraw”=>10}
grouped_attribution.where("event = ? OR event = ?", Attribution::VISIT, Attribution::SIGN_UP).sum(:bonus_amount)
(1.0ms) SELECT SUM(`attributions`.`bonus_amount`) AS sum_bonus_amount, event AS event FROM `attributions` WHERE (event = ‘visit’ OR event = ‘sign_up’) GROUP BY event
=> {“sign_up”=>10000, “visit”=>15000}
grouped_attribution.where("event = ? OR event = ?", Attribution::ORDER_DONE, Attribution::WITHDRAW).sum(:bonus_amount)
(1.4ms) SELECT SUM(`attributions`.`bonus_amount`) AS sum_bonus_amount, event AS event FROM `attributions` WHERE (event = ‘order_done’ OR event = ‘withdraw’) GROUP BY event
=> {“order_done”=>600, “withdraw”=>10}
stacktrace
ArgumentError - Unknown key: deposit:
activesupport (4.0.12) lib/active_support/core_ext/hash/keys.rb:70:in `block in assert_valid_keys'
activesupport (4.0.12) lib/active_support/core_ext/hash/keys.rb:69:in `assert_valid_keys'
activerecord-deprecated_finders (1.0.3) lib/active_record/deprecated_finders/relation.rb:18:in `apply_finder_options'
activerecord-deprecated_finders (1.0.3) lib/active_record/deprecated_finders/base.rb:46:in `call'
activerecord (4.0.12) lib/active_record/scoping/named.rb:163:in `block (2 levels) in scope'
activerecord (4.0.12) lib/active_record/relation.rb:270:in `scoping'
activerecord (4.0.12) lib/active_record/scoping/named.rb:163:in `block in scope'
app/helpers/attribution_helper.rb:10:in `block in statistics'
app/helpers/attribution_helper.rb:10:in `statistics'
app/views/price_widgets/dashboard.html.slim:38:in `block in _app_views_price_widgets_dashboard_html_slim___3846780147619711966_70216357117460'
actionpack (4.0.12) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionpack (4.0.12) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
actionpack (4.0.12) lib/action_view/helpers/capture_helper.rb:38:in `capture'
actionpack (4.0.12) lib/action_view/helpers/capture_helper.rb:152:in `content_for'
app/views/price_widgets/dashboard.html.slim:4:in `_app_views_price_widgets_dashboard_html_slim___3846780147619711966_70216357117460'
actionpack (4.0.12) lib/action_view/template.rb:143:in `block in render'
activesupport (4.0.12) lib/active_support/notifications.rb:161:in `instrument'
actionpack (4.0.12) lib/action_view/template.rb:141:in `render'
actionpack (4.0.12) lib/action_view/renderer/template_renderer.rb:49:in `block (2 levels) in render_template'
actionpack (4.0.12) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (4.0.12) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.12) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.12) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.12) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (4.0.12) lib/action_view/renderer/template_renderer.rb:48:in `block in render_template'
actionpack (4.0.12) lib/action_view/renderer/template_renderer.rb:56:in `render_with_layout'
actionpack (4.0.12) lib/action_view/renderer/template_renderer.rb:47:in `render_template'
actionpack (4.0.12) lib/action_view/renderer/template_renderer.rb:17:in `render'
actionpack (4.0.12) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionpack (4.0.12) lib/action_view/renderer/renderer.rb:23:in `render'
actionpack (4.0.12) lib/abstract_controller/rendering.rb:127:in `_render_template'
actionpack (4.0.12) lib/action_controller/metal/streaming.rb:219:in `_render_template'
actionpack (4.0.12) lib/abstract_controller/rendering.rb:120:in `render_to_body'
actionpack (4.0.12) lib/action_controller/metal/rendering.rb:33:in `render_to_body'
actionpack (4.0.12) lib/action_controller/metal/renderers.rb:26:in `render_to_body'
actionpack (4.0.12) lib/abstract_controller/rendering.rb:97:in `render'
actionpack (4.0.12) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.0.12) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.0.12) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/Users/tiwa/.rbenv/versions/2.2.2/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
activesupport (4.0.12) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.0.12) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.0.12) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.0.12) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.0.12) lib/action_controller/metal/instrumentation.rb:40:in `render'
actionpack (4.0.12) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.0.12) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (4.0.12) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.0.12) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.0.12) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (4.0.12) lib/active_support/callbacks.rb:483:in `_run__2112368623363193916__process_action__callbacks'
activesupport (4.0.12) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.12) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (4.0.12) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.0.12) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.0.12) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.12) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.12) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.12) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.0.12) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.0.12) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.0.12) lib/abstract_controller/base.rb:136:in `process'
actionpack (4.0.12) lib/abstract_controller/rendering.rb:44:in `process'
actionpack (4.0.12) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.0.12) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.0.12) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.0.12) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
actionpack (4.0.12) lib/action_dispatch/routing/route_set.rb:50:in `call'
actionpack (4.0.12) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.12) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.12) lib/action_dispatch/routing/route_set.rb:676:in `call'
omniauth (1.2.2) lib/omniauth/strategy.rb:404:in `call_app!'
omniauth-identity (1.1.1) lib/omniauth/strategies/identity.rb:43:in `other_phase'
omniauth (1.2.2) lib/omniauth/strategy.rb:185:in `call!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.2) lib/omniauth/builder.rb:59:in `call'
meta_request (0.2.8) lib/meta_request/middlewares/app_request_handler.rb:13:in `call'
rack-contrib (1.1.0) lib/rack/contrib/response_headers.rb:17:in `call'
meta_request (0.2.8) lib/meta_request/middlewares/headers.rb:16:in `call'
meta_request (0.2.8) lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
http_accept_language (2.0.1) lib/http_accept_language/middleware.rb:13:in `call'
simple_captcha2 (0.2.2) lib/simple_captcha/middleware.rb:20:in `call'
rack (1.5.5) lib/rack/etag.rb:23:in `call'
rack (1.5.5) lib/rack/conditionalget.rb:35:in `call'
rack (1.5.5) lib/rack/head.rb:11:in `call'
actionpack (4.0.12) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.0.12) lib/action_dispatch/middleware/flash.rb:241: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'
actionpack (4.0.12) lib/action_dispatch/middleware/cookies.rb:486:in `call'
activerecord (4.0.12) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.12) lib/active_record/migration.rb:373:in `call'
actionpack (4.0.12) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.12) lib/active_support/callbacks.rb:373:in `_run__2834334812182002754__call__callbacks'
activesupport (4.0.12) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.12) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.12) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.12) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
better_errors (1.1.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (1.1.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (1.1.0) lib/better_errors/middleware.rb:56:in `call'
bugsnag (6.11.0) lib/bugsnag/integrations/rack.rb:46:in `call'
actionpack (4.0.12) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.12) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.12) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.12) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.0.12) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.0.12) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.0.12) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.0.12) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.0.2) lib/quiet_assets.rb:18:in `call_with_quiet_assets'
request_store (1.1.0) lib/request_store/middleware.rb:8:in `call'
actionpack (4.0.12) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.5) lib/rack/runtime.rb:17:in `call'
lib/middleware/security.rb:11:in `call'
rack (1.5.5) lib/rack/lock.rb:17:in `call'
actionpack (4.0.12) lib/action_dispatch/middleware/static.rb:84:in `call'
lib/middleware/i18n_js.rb:9:in `call'
rack (1.5.5) lib/rack/sendfile.rb:112:in `call'
rack-cors (1.0.2) lib/rack/cors.rb:97:in `call'
railties (4.0.12) lib/rails/engine.rb:511:in `call'
railties (4.0.12) lib/rails/application.rb:97:in `call'
railties (4.0.12) lib/rails/railtie/configurable.rb:30:in `method_missing'
rack-reverse-proxy (0.12.0) lib/rack_reverse_proxy/roundtrip.rb:19:in `call'
rack-reverse-proxy (0.12.0) lib/rack_reverse_proxy/middleware.rb:25:in `call'
rack (1.5.5) lib/rack/lock.rb:17:in `call'
rack (1.5.5) lib/rack/content_length.rb:14:in `call'
rack (1.5.5) lib/rack/handler/webrick.rb:60:in `service'
I've been working with the shoppe gem, and I'm currently completely stumped by an error I'm getting when I'm opening up the orders page of the admin panel.
I'm using version 1.0.7 because product variants broke on the subsequent ones. Everything was working completely fine until I merged with a different branch in my repo, and now when I try to access the orders page of the admin panel this happens:
ActionView::Template::Error (undefined method `entry_name' for #<ActiveRecord::Relation []>):
6: = link_to t('shoppe.orders.search_orders'), '#', :class => 'button', :rel => 'searchOrders'
7: %h2.orders
8: = t('shoppe.orders.orders')
9: %span= page_entries_info #orders
10:
11: = render 'search_form'
12:
activerecord (4.2.4) lib/active_record/relation/delegation.rb:136:in `method_missing'
activerecord (4.2.4) lib/active_record/relation/delegation.rb:99:in `method_missing'
kaminari (0.16.3) lib/kaminari/helpers/action_view_extension.rb:92:in `page_entries_info'
shoppe (1.0.7) app/views/shoppe/orders/index.html.haml:9:in `block in ___sers_aur______rvm_gems_ruby_______gems_shoppe_______app_views_shoppe_orders_index_html_haml__4424402014120534252_70189058436720'
haml (4.0.7) lib/haml/helpers.rb:368:in `call'
haml (4.0.7) lib/haml/helpers.rb:368:in `block in capture_haml'
haml (4.0.7) lib/haml/helpers.rb:608:in `with_haml_buffer'
haml (4.0.7) lib/haml/helpers.rb:364:in `capture_haml'
haml (4.0.7) lib/haml/helpers/xss_mods.rb:61:in `capture_haml_with_haml_xss'
haml (4.0.7) lib/haml/helpers/action_view_mods.rb:45:in `capture_with_haml'
actionview (4.2.4) lib/action_view/helpers/capture_helper.rb:152:in `content_for'
shoppe (1.0.7) app/views/shoppe/orders/index.html.haml:3:in `___sers_aur______rvm_gems_ruby_______gems_shoppe_______app_views_shoppe_orders_index_html_haml__4424402014120534252_70189058436720'
actionview (4.2.4) lib/action_view/template.rb:145:in `block in render'
activesupport (4.2.4) lib/active_support/notifications.rb:166:in `instrument'
actionview (4.2.4) lib/action_view/template.rb:333:in `instrument'
actionview (4.2.4) lib/action_view/template.rb:143:in `render'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
actionview (4.2.4) lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
activesupport (4.2.4) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.4) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.4) lib/active_support/notifications.rb:164:in `instrument'
actionview (4.2.4) lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (4.2.4) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (4.2.4) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (4.2.4) lib/action_view/rendering.rb:100:in `_render_template'
actionpack (4.2.4) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.2.4) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (4.2.4) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.2.4) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
actionpack (4.2.4) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.2.4) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (4.2.4) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/Users/aur2103/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
activesupport (4.2.4) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (4.2.4) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:43:in `render'
actionpack (4.2.4) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.2.4) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (4.2.4) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.4) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.4) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.4) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
activesupport (4.2.4) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:92:in `__run_callbacks__'
activesupport (4.2.4) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
activesupport (4.2.4) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.4) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.4) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (4.2.4) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.4) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.4) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.4) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.4) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.4) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.4) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.4) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.2.4) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.4) lib/action_controller/metal.rb:237:in `block in action'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:76:in `call'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:76:in `dispatch'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:45:in `serve'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:821:in `call'
railties (4.2.4) lib/rails/engine.rb:518:in `call'
railties (4.2.4) lib/rails/railtie.rb:194:in `public_send'
railties (4.2.4) lib/rails/railtie.rb:194:in `method_missing'
actionpack (4.2.4) lib/action_dispatch/routing/mapper.rb:51:in `serve'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:821:in `call'
shoppe (1.0.7) lib/shoppe/settings_loader.rb:10:in `call'
nifty-attachments (1.0.4) lib/nifty/attachments/middleware.rb:23: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.6.4) lib/rack/etag.rb:24:in `call'
rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.4) lib/rack/head.rb:13:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.4) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
activerecord (4.2.4) lib/active_record/migration.rb:377:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.4) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
activesupport (4.2.4) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
activesupport (4.2.4) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.4) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.4) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.4) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.4) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.4) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.4) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.4) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.4) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/static.rb:116:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
railties (4.2.4) lib/rails/engine.rb:518:in `call'
railties (4.2.4) lib/rails/application.rb:165:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
rack (1.6.4) lib/rack/content_length.rb:15:in `call'
rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
/Users/aur2103/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/Users/aur2103/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/Users/aur2103/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
I know that this is happening in the page_entries_info method in kaminari. This one, specifically the second line within the method:
def page_entries_info(collection, options = {})
entry_name = options[:entry_name] || collection.entry_name
entry_name = entry_name.pluralize unless collection.total_count == 1
if collection.total_pages < 2
t('helpers.page_entries_info.one_page.display_entries', :entry_name => entry_name, :count => collection.total_count)
else
first = collection.offset_value + 1
last = collection.last_page? ? collection.total_count : collection.offset_value + collection.limit_value
t('helpers.page_entries_info.more_pages.display_entries', :entry_name => entry_name, :first => first, :last => last, :total => collection.total_count)
end.html_safe
end
The strange thing is, I've put in some print statements in both the functioning version and the broken version, and in BOTH of them options[:entry_name] is nil and collection.inspect prints out #<ActiveRecord::Relation []>. However, only the newly merged version throws the error. Why does #<ActiveRecord::Relation []> not have this method in only one of the branches? What could be causing this?
Are you using will_paginate or bootstrap-will_paginate ?
Please see here: https://github.com/tryshoppe/shoppe/issues/189
I will also suggest the following:
1. Kill your rails server
2. type "spring stop"
3. bundle/restart rails
I had this same issue with entry_name without using will_paginate so the second fix worked for me.
Explicitly declaring entry_name in the line that calls page_entries_info is what solved it for me.
<%= page_entries_info #orders, entry_name: "order" =>
See the solution here.
I'm using monologue engine to creata a blog. I follow the readme file at https://github.com/jipiboily/monologue to config my app and database.
When i try to create a new article using monologue interface i get this error: undefined method 'year' for nil:NilClass.
Someone does know how to fix it?
Complete log file:
NoMethodError (undefined method `year' for nil:NilClass):
activesupport (4.1.1) lib/active_support/values/time_zone.rb:290:in `parse'
activesupport (4.1.1) lib/active_support/core_ext/string/zones.rb:9:in `in_time_zone'
activerecord (4.1.1) lib/active_record/attribute_methods/time_zone_conversion.rb:37:in `published_at='
activerecord (4.1.1) lib/active_record/attribute_assignment.rb:45:in `public_send'
activerecord (4.1.1) lib/active_record/attribute_assignment.rb:45:in `_assign_attribute'
activerecord (4.1.1) lib/active_record/attribute_assignment.rb:32:in `block in assign_attributes'
activerecord (4.1.1) lib/active_record/attribute_assignment.rb:26:in `each'
activerecord (4.1.1) lib/active_record/attribute_assignment.rb:26:in `assign_attributes'
activerecord (4.1.1) lib/active_record/core.rb:452:in `init_attributes'
activerecord (4.1.1) lib/active_record/core.rb:198:in `initialize'
activerecord (4.1.1) lib/active_record/inheritance.rb:30:in `new'
activerecord (4.1.1) lib/active_record/inheritance.rb:30:in `new'
monologue (0.4.1) app/controllers/monologue/admin/posts_controller.rb:24:in `create'
actionpack (4.1.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.1) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.1) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:676:in `call'
railties (4.1.1) lib/rails/engine.rb:514:in `call'
railties (4.1.1) lib/rails/railtie.rb:194:in `public_send'
railties (4.1.1) lib/rails/railtie.rb:194:in `method_missing'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:676:in `call'
rack (1.5.4) lib/rack/etag.rb:23:in `call'
rack (1.5.4) lib/rack/conditionalget.rb:35:in `call'
rack (1.5.4) lib/rack/head.rb:11:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.4) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.4) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.1) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
activerecord (4.1.1) lib/active_record/migration.rb:380:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.1) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.4) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.4) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.1) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.4) lib/rack/lock.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.4) lib/rack/sendfile.rb:112:in `call'
railties (4.1.1) lib/rails/engine.rb:514:in `call'
railties (4.1.1) lib/rails/application.rb:144:in `call'
rack (1.5.4) lib/rack/lock.rb:17:in `call'
rack (1.5.4) lib/rack/content_length.rb:14:in `call'
rack (1.5.4) lib/rack/handler/webrick.rb:60:in `service'
/usr/local/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/usr/local/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/usr/local/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
I resolved using ruby 2.1.2.
Thanks to all!
It's actually a bug with rails, the fix is to update Rails as you can see in this commit
https://github.com/rails/rails/commit/e88da370f190cabd1e9750c5b3531735950ab415
I'm following the onemonthrails tutorial, and I'm in the "New User Signup and Signin" lesson. I followed all the steps correctly, but I'm running into an error :
"ActiveRecord::StatementInvalid in Devise::RegistrationsController#new
Could not find table 'users'"
The only thing that was different on my terminal than the teacher's one is the "run db:migrate" that doesn't do anything...
The full error trace gives me this :
activerecord (4.1.0) lib/active_record/connection_adapters/sqlite3_adapter.rb:512:in `table_structure'
activerecord (4.1.0) lib/active_record/connection_adapters/sqlite3_adapter.rb:387:in `columns'
activerecord (4.1.0) lib/active_record/connection_adapters/schema_cache.rb:93:in `block in prepare_default_proc'
activerecord (4.1.0) lib/active_record/connection_adapters/schema_cache.rb:44:in `yield'
activerecord (4.1.0) lib/active_record/connection_adapters/schema_cache.rb:44:in `columns'
activerecord (4.1.0) lib/active_record/model_schema.rb:214:in `columns'
activerecord (4.1.0) lib/active_record/model_schema.rb:223:in `columns_hash'
activerecord (4.1.0) lib/active_record/inheritance.rb:180:in `subclass_from_attributes?'
activerecord (4.1.0) lib/active_record/inheritance.rb:23:in `new'
devise (3.1.2) lib/devise/models/registerable.rb:20:in `new_with_session'
devise (3.1.2) app/controllers/devise/registrations_controller.rb:92:in `build_resource'
devise (3.1.2) app/controllers/devise/registrations_controller.rb:7:in `new'
actionpack (4.1.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.0) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.0) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.0) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.0) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.0) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.0) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.0) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.0) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.0) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.0) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.1.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.0) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.1.0) lib/action_dispatch/routing/mapper.rb:45:in `call'
actionpack (4.1.0) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.0) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.0) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:676: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.1.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.0) lib/action_dispatch/middleware/flash.rb:254: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.1.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
activerecord (4.1.0) lib/active_record/migration.rb:380:in `call'
actionpack (4.1.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.0) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.0) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.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.1.0) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.0) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.0) lib/rails/engine.rb:514:in `call'
railties (4.1.0) lib/rails/application.rb:144: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'
/Users/pablofaust/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
/Users/pablofaust/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
/Users/pablofaust/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
What should I do ?
Clearly your migrate is trying to do something to the Users table but it doesn't exist. Try rake db:migrate VERSION=0 and then rake db:migrate again to start fresh*. If you run into an error on the down-rake, you can go into your db and delete the database and re-create it to start fresh*.
If you're still having problems, there must be a typo in your migration file(s).
*Note that 'starting fresh' will trash all the data in your database if there is any.
Migrate the database as:--
rake db:migrate
First make sure the database exists
rake db:create
Then run the migration which is created by devise
rake db:migrate
I updated from RoR 4.0.4 to 4.1.1 to apply the latest security patch and it appears pg_search broke.
Here's a error:
PG::SyntaxError: ERROR: syntax error at or near "AS"
LINE 1: ...sh', ''' ' || unaccent('banner') || ' ''')), 0))) AS pg_sear...
I'm searching via ajax but i don't think that is the issue based on the output above. I'm also using will_paginate but the branch I'm using is supposed to fix previous issues with rails 4.1.x and pg_search.
gem 'will_paginate', :git => 'https://github.com/nazgum/will_paginate.git' #until rails 4.1 will_paginate fixed
This is the code model where i'm executing the search:
include PgSearch
pg_search_scope :search, against: [:title, :body],
using: {tsearch: {dictionary: "english"}},
ignoring: :accents
def self.text_search(query)
if query.present?
search(query)
else
scoped
end
end
Everything was working prior to the RoR version bump - hoping someone might have some advice.
Here's the full stacktrace:
: SELECT COUNT("photos".*, ((ts_rank((to_tsvector('english', unaccent(coalesce("photos"."description"::text, ''))) || to_tsvector('english', unaccent(coalesce(pg_search_3b58f11462e6f0086ceffb.pg_search_dc60169d7766a303bd09de::text, '')))), (to_tsquery('english', ''' ' || unaccent('"banner"') || ' ''')), 0))) AS pg_search_rank) FROM "photos" LEFT OUTER JOIN (SELECT "photos"."id" AS id, string_agg("products"."name"::text, ' ') AS pg_search_dc60169d7766a303bd09de FROM "photos" INNER JOIN "products" ON "products"."id" = "photos"."product_id" GROUP BY "photos"."id") pg_search_3b58f11462e6f0086ceffb ON pg_search_3b58f11462e6f0086ceffb.id = "photos"."id" WHERE "photos"."placement" = 'showcase' AND (((to_tsvector('english', unaccent(coalesce("photos"."description"::text, ''))) || to_tsvector('english', unaccent(coalesce(pg_search_3b58f11462e6f0086ceffb.pg_search_dc60169d7766a303bd09de::text, '')))) ## (to_tsquery('english', ''' ' || unaccent('"banner"') || ' ''')))) AND "photos"."is_active" = 't':
activerecord (4.1.1) lib/active_record/connection_adapters/abstract_adapter.rb:362:in `translate_exception_class'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract_adapter.rb:375:in `rescue in log'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract_adapter.rb:373:in `log'
activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:815:in `exec_no_cache'
activerecord (4.1.1) lib/active_record/connection_adapters/postgresql/database_statements.rb:137:in `exec_query'
activerecord (4.1.1) lib/active_record/connection_adapters/postgresql_adapter.rb:947:in `select'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/database_statements.rb:31:in `select_all'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/query_cache.rb:67:in `block in select_all'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/query_cache.rb:82:in `cache_sql'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/query_cache.rb:67:in `select_all'
activerecord (4.1.1) lib/active_record/relation/calculations.rb:254:in `execute_simple_calculation'
activerecord (4.1.1) lib/active_record/relation/calculations.rb:216:in `perform_calculation'
activerecord (4.1.1) lib/active_record/relation/calculations.rb:111:in `calculate'
activerecord (4.1.1) lib/active_record/relation/calculations.rb:26:in `count'
app/views/showcases/_index.html.haml:1:in `_app_views_showcases__index_html_haml__780171647705973812_70320535206900'
actionview (4.1.1) lib/action_view/template.rb:145:in `block in render'
activesupport (4.1.1) lib/active_support/notifications.rb:161:in `instrument'
actionview (4.1.1) lib/action_view/template.rb:339:in `instrument'
actionview (4.1.1) lib/action_view/template.rb:143:in `render'
actionview (4.1.1) lib/action_view/renderer/partial_renderer.rb:306:in `render_partial'
actionview (4.1.1) lib/action_view/renderer/partial_renderer.rb:279:in `block in render'
actionview (4.1.1) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `instrument'
actionview (4.1.1) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionview (4.1.1) lib/action_view/renderer/partial_renderer.rb:278:in `render'
actionview (4.1.1) lib/action_view/renderer/renderer.rb:47:in `render_partial'
actionview (4.1.1) lib/action_view/renderer/renderer.rb:21:in `render'
actionview (4.1.1) lib/action_view/helpers/rendering_helper.rb:32:in `render'
haml (4.0.5) lib/haml/helpers/action_view_mods.rb:12:in `render_with_haml'
app/views/showcases/index.js.erb:4:in `_app_views_showcases_index_js_erb__1635704546300671617_70320482208180'
actionview (4.1.1) lib/action_view/template.rb:145:in `block in render'
activesupport (4.1.1) lib/active_support/notifications.rb:161:in `instrument'
actionview (4.1.1) lib/action_view/template.rb:339:in `instrument'
actionview (4.1.1) lib/action_view/template.rb:143:in `render'
actionview (4.1.1) lib/action_view/renderer/template_renderer.rb:55:in `block (2 levels) in render_template'
actionview (4.1.1) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `instrument'
actionview (4.1.1) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionview (4.1.1) lib/action_view/renderer/template_renderer.rb:54:in `block in render_template'
actionview (4.1.1) lib/action_view/renderer/template_renderer.rb:62:in `render_with_layout'
actionview (4.1.1) lib/action_view/renderer/template_renderer.rb:53:in `render_template'
actionview (4.1.1) lib/action_view/renderer/template_renderer.rb:17:in `render'
actionview (4.1.1) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (4.1.1) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (4.1.1) lib/action_view/rendering.rb:99:in `_render_template'
actionpack (4.1.1) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.1.1) lib/action_view/rendering.rb:82:in `render_to_body'
actionpack (4.1.1) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.1.1) lib/action_controller/metal/renderers.rb:32:in `render_to_body'
actionpack (4.1.1) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.1.1) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.1.1) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/Users/bret/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
activesupport (4.1.1) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.1.1) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:40:in `render'
actionpack (4.1.1) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.1.1) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.1) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.1) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:676:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:404:in `call_app!'
omniauth-identity (1.1.1) lib/omniauth/strategies/identity.rb:43:in `other_phase'
omniauth (1.2.1) lib/omniauth/strategy.rb:185:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/builder.rb:59: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.1.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/flash.rb:254: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.1.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.1) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.1) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
better_errors (1.1.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (1.1.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (1.1.0) lib/better_errors/middleware.rb:56:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.0.2) lib/quiet_assets.rb:18:in `call_with_quiet_assets'
actionpack (4.1.1) 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.1.1) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
sentry-raven (0.8.0) lib/raven/rack.rb:47:in `call'
railties (4.1.1) lib/rails/engine.rb:514:in `call'
railties (4.1.1) lib/rails/application.rb:144:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
railties (4.1.1) lib/rails/rack/debugger.rb:20: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.1) lib/rails/commands/server.rb:69:in `start'
railties (4.1.1) lib/rails/commands/commands_tasks.rb:81:in `block in server'
railties (4.1.1) lib/rails/commands/commands_tasks.rb:76:in `server'
railties (4.1.1) lib/rails/commands/commands_tasks.rb:40:in `run_command!'
railties (4.1.1) lib/rails/commands.rb:17:in `<top (required)>'
bin/rails:4:in `<main>'
#supports.count(:all) should work, the #supports.count syntax got deprecated in rails 4.1.1
There is a good conversation here to clarify the problem.
This is weird - when i call
=#supports.count
the error is generated but it is a valid object. It's a bit hacky but this is working for now:
=#supports.to_a.count