ging / avatars_for_rails

A Rails gem to manage avatars
MIT License
45 stars 27 forks source link

NameError - undefined local variable or method `avatarable' #16

Closed danil-z closed 11 years ago

danil-z commented 11 years ago

Hello. i'm wondering why do i get this error when i try render 'avatars/form' partial?

Started GET "/users/1" for 127.0.0.1 at 2013-06-19 19:10:04 +0400
Processing by UsersController#show as HTML
  Parameters: {"id"=>"1"}
  User Load (0.2ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 2 LIMIT 1
  User Load (0.1ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", "1"]]
  Rendered /Users/danil/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/avatars_for_rails-1.1.1/app/views/avatars/_form.html.erb (16.5ms)
  Rendered users/show.html.slim within layouts/application (20.3ms)
Completed 500 Internal Server Error in 24ms

NameError - undefined local variable or method `avatarable' for #<#<Class:0x007fc27d4a7e40>:0x007fc27bc01eb8>:
  avatars_for_rails (1.1.1) app/views/avatars/_form.html.erb:2:in `___sers_danil__rbenv_versions_______p____lib_ruby_gems_______gems_avatars_for_rails_______app_views_avatars__form_html_erb__3056722547818066022_70236681185860'
  actionpack (3.2.13) lib/action_view/template.rb:145:in `block in render'
  activesupport (3.2.13) lib/active_support/notifications.rb:125:in `instrument'
  actionpack (3.2.13) lib/action_view/template.rb:143:in `render'
  actionpack (3.2.13) lib/action_view/renderer/partial_renderer.rb:265:in `render_partial'
  actionpack (3.2.13) lib/action_view/renderer/partial_renderer.rb:238:in `block in render'
  actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
  activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
  actionpack (3.2.13) lib/action_view/renderer/partial_renderer.rb:237:in `render'
  actionpack (3.2.13) lib/action_view/renderer/renderer.rb:41:in `render_partial'
  actionpack (3.2.13) lib/action_view/renderer/renderer.rb:15:in `render'
  actionpack (3.2.13) lib/action_view/helpers/rendering_helper.rb:24:in `render'
  haml (4.0.3) lib/haml/helpers/action_view_mods.rb:12:in `render_with_haml'
  app/views/users/show.html.slim:3:in `_app_views_users_show_html_slim__2238102332986823369_70236638303980'
  actionpack (3.2.13) lib/action_view/template.rb:145:in `block in render'
  activesupport (3.2.13) lib/active_support/notifications.rb:125:in `instrument'
  actionpack (3.2.13) lib/action_view/template.rb:143:in `render'
  actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template'
  actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
  activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
  actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:46:in `block in render_template'
  actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout'
  actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:45:in `render_template'
  actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:18:in `render'
  actionpack (3.2.13) lib/action_view/renderer/renderer.rb:36:in `render_template'
  actionpack (3.2.13) lib/action_view/renderer/renderer.rb:17:in `render'
  actionpack (3.2.13) lib/abstract_controller/rendering.rb:110:in `_render_template'
  actionpack (3.2.13) lib/action_controller/metal/streaming.rb:225:in `_render_template'
  actionpack (3.2.13) lib/abstract_controller/rendering.rb:103:in `render_to_body'
  actionpack (3.2.13) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
  actionpack (3.2.13) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
  actionpack (3.2.13) lib/abstract_controller/rendering.rb:88:in `render'
  actionpack (3.2.13) lib/action_controller/metal/rendering.rb:16:in `render'
  actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
  activesupport (3.2.13) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
  /Users/danil/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
  activesupport (3.2.13) lib/active_support/core_ext/benchmark.rb:5:in `ms'
  actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
  actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
  activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
  actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:39:in `render'
  actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
  actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
  actionpack (3.2.13) lib/abstract_controller/base.rb:167:in `process_action'
  actionpack (3.2.13) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (3.2.13) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  activesupport (3.2.13) lib/active_support/callbacks.rb:425:in `_run__3633259458467001365__process_action__2229307282374367166__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_process_action_callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action'
  actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
  activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (3.2.13) lib/abstract_controller/base.rb:121:in `process'
  actionpack (3.2.13) lib/abstract_controller/rendering.rb:45:in `process'
  actionpack (3.2.13) lib/action_controller/metal.rb:203:in `dispatch'
  actionpack (3.2.13) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  actionpack (3.2.13) lib/action_controller/metal.rb:246:in `block in action'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `call'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:36:in `call'
  journey (1.0.4) lib/journey/router.rb:68:in `block in call'
  journey (1.0.4) lib/journey/router.rb:56:in `each'
  journey (1.0.4) lib/journey/router.rb:56:in `call'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
  warden (1.2.1) lib/warden/manager.rb:35:in `block in call'
  warden (1.2.1) lib/warden/manager.rb:34:in `catch'
  warden (1.2.1) lib/warden/manager.rb:34:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.5) lib/rack/etag.rb:23:in `call'
  rack (1.4.5) lib/rack/conditionalget.rb: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__3520368486053266372__call__2548956666338047504__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/reloader.rb:65:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  better_errors (0.9.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (0.9.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (0.9.0) lib/better_errors/middleware.rb:56: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'
  quiet_assets (1.0.2) lib/quiet_assets.rb:18:in `call_with_quiet_assets'
  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'
  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'
  unicorn (4.6.2) lib/unicorn/http_server.rb:552:in `process_client'
  unicorn (4.6.2) lib/unicorn/http_server.rb:632:in `worker_loop'
  unicorn (4.6.2) lib/unicorn/http_server.rb:500:in `spawn_missing_workers'
  unicorn (4.6.2) lib/unicorn/http_server.rb:142:in `start'
  unicorn (4.6.2) bin/unicorn_rails:209:in `<top (required)>'
  /Users/danil/.rbenv/versions/2.0.0-p195/bin/unicorn_rails:23:in `load'
  /Users/danil/.rbenv/versions/2.0.0-p195/bin/unicorn_rails:23:in `<top (required)>'
  -e:1:in `load'
  -e:1:in `<main>'
danil-z commented 11 years ago

my User model looks like:

class User < ActiveRecord::Base
  rolify
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable
  attr_accessible :role_ids, :as => :admin
  attr_accessible :name, :email, :password, :password_confirmation, :remember_me
  acts_as_avatarable
end

config/initializers/avatars_for_rails.rb

AvatarsForRails.setup do |config|
  config.controller_filters = [ :authenticate_user! ]
  config.controller_avatarable = :current_user
  config.avatarable_styles = { small:  '50x50',
                                medium: '120x120' }
end
atd commented 11 years ago

Hi @blackbumer you need to pass the avatarable object. I have improved the documentation with an example on how to achieve it

CraneWing commented 9 years ago

Hello, I was wondering if this gem was still active. It doesn't come up at RubyGems at all nor when I run bundle install.