merit-gem / merit

Reputation engine for Rails apps
Other
1.53k stars 198 forks source link

can't write unknown attribute `sash_id' #158

Closed marcosgugs closed 10 years ago

marcosgugs commented 10 years ago

In Rails 4.1, I have this error when using merit.

Any idea?

Started POST "/posts" for 127.0.0.1 at 2014-04-11 23:04:28 -0300
Processing by PostsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"9yVIEpHYu3uGK5j+txFw/F1gQOJJq/R2o7QcAU6Mugg=", "post"=>{"title"=>"", "description"=>"new post", "image_url"=>"", "video_url"=>"", "post_image_url"=>"", "link_url"=>""}, "commit"=>"Create Post"}
  User Load (0.5ms)  SELECT  `users`.* FROM `users`  WHERE `users`.`id` = 1  ORDER BY `users`.`id` ASC LIMIT 1
   (0.2ms)  BEGIN
  SQL (16.4ms)  INSERT INTO `posts` (`created_at`, `description`, `image_url`, `link_url`, `post_image_url`, `title`, `updated_at`, `user_id`, `video_url`) VALUES ('2014-04-12 02:04:28', 'new post', '', '', '', '', '2014-04-12 02:04:28', 1, '')
   (18.0ms)  COMMIT
Redirected to http://localhost:3000/posts
   (0.2ms)  BEGIN
  SQL (1.5ms)  INSERT INTO `merit_actions` (`action_method`, `created_at`, `target_id`, `target_model`, `updated_at`, `user_id`) VALUES ('create', '2014-04-12 02:04:28', 12, 'posts', '2014-04-12 02:04:28', 1)
   (0.3ms)  COMMIT
  Merit::Action Load (0.4ms)  SELECT `merit_actions`.* FROM `merit_actions`  WHERE `merit_actions`.`processed` = 0
   (0.1ms)  BEGIN
  SQL (0.5ms)  UPDATE `merit_actions` SET `processed` = 1, `updated_at` = '2014-04-12 02:04:28' WHERE `merit_actions`.`id` = 3
   (0.3ms)  COMMIT
  Post Load (0.4ms)  SELECT  `posts`.* FROM `posts`  WHERE `posts`.`id` = 12 LIMIT 1
  User Load (0.3ms)  SELECT  `users`.* FROM `users`  WHERE `users`.`id` = 1 LIMIT 1
   (0.1ms)  BEGIN
  SQL (9.7ms)  INSERT INTO `sashes` (`created_at`, `updated_at`) VALUES ('2014-04-12 02:04:28', '2014-04-12 02:04:28')
  SQL (0.4ms)  INSERT INTO `merit_scores` VALUES ()
  SQL (1.6ms)  UPDATE `merit_scores` SET `sash_id` = 4 WHERE `merit_scores`.`id` = 4
   (0.4ms)  COMMIT
   (0.2ms)  BEGIN
   (1.2ms)  ROLLBACK
Completed 500 Internal Server Error in 173ms

ActiveModel::MissingAttributeError (can't write unknown attribute `sash_id'):
  activerecord (4.1.0.rc1) lib/active_record/attribute_methods/write.rb:72:in `write_attribute'
  activerecord (4.1.0.rc1) lib/active_record/attribute_methods/dirty.rb:68:in `write_attribute'
  activerecord (4.1.0.rc1) lib/active_record/attribute_methods.rb:387:in `[]='
  activerecord (4.1.0.rc1) lib/active_record/associations/belongs_to_association.rb:70:in `replace_keys'
  activerecord (4.1.0.rc1) lib/active_record/associations/belongs_to_association.rb:14:in `replace'
  activerecord (4.1.0.rc1) lib/active_record/associations/singular_association.rb:17:in `writer'
  activerecord (4.1.0.rc1) lib/active_record/associations/builder/association.rb:118:in `sash='
  activerecord (4.1.0.rc1) lib/active_record/attribute_assignment.rb:45:in `public_send'
  activerecord (4.1.0.rc1) lib/active_record/attribute_assignment.rb:45:in `_assign_attribute'
  activerecord (4.1.0.rc1) lib/active_record/attribute_assignment.rb:32:in `block in assign_attributes'
  activerecord (4.1.0.rc1) lib/active_record/attribute_assignment.rb:26:in `each'
  activerecord (4.1.0.rc1) lib/active_record/attribute_assignment.rb:26:in `assign_attributes'
  activerecord (4.1.0.rc1) lib/active_record/persistence.rb:231:in `block in update'
  activerecord (4.1.0.rc1) lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
  activerecord (4.1.0.rc1) lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `block in transaction'
  activerecord (4.1.0.rc1) lib/active_record/connection_adapters/abstract/database_statements.rb:219:in `within_new_transaction'
  activerecord (4.1.0.rc1) lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
  activerecord (4.1.0.rc1) lib/active_record/transactions.rb:208:in `transaction'
  activerecord (4.1.0.rc1) lib/active_record/transactions.rb:326:in `with_transaction_returning_status'
  activerecord (4.1.0.rc1) lib/active_record/persistence.rb:230:in `update'
  /Users/tabata/.rvm/gems/ruby-2.1.0@rails41/bundlermerit (9905df1bafa0) lib/merit/model_additions.rb:52:in `block in _merit_sash_initializer'
  /Users/tabata/.rvm/gems/ruby-2.1.0@rails41/bundlermerit (9905df1bafa0) lib/merit/sash_finder.rb:4:in `map'
  /Users/tabata/.rvm/gems/ruby-2.1.0@rails41/bundlermerit (9905df1bafa0) lib/merit/sash_finder.rb:4:in `find'
  /Users/tabata/.rvm/gems/ruby-2.1.0@rails41/bundlermerit (9905df1bafa0) lib/merit/judge.rb:87:in `sashes'
  /Users/tabata/.rvm/gems/ruby-2.1.0@rails41/bundlermerit (9905df1bafa0) lib/merit/judge.rb:27:in `apply_points'
  /Users/tabata/.rvm/gems/ruby-2.1.0@rails41/bundlermerit (9905df1bafa0) app/models/merit/action.rb:35:in `block in check_rules'
  /Users/tabata/.rvm/gems/ruby-2.1.0@rails41/bundlermerit (9905df1bafa0) app/models/merit/action.rb:33:in `each'
  /Users/tabata/.rvm/gems/ruby-2.1.0@rails41/bundlermerit (9905df1bafa0) app/models/merit/action.rb:33:in `check_rules'
  /Users/tabata/.rvm/gems/ruby-2.1.0@rails41/bundlermerit (9905df1bafa0) app/models/merit/action.rb:27:in `check_all_rules'
  activerecord (4.1.0.rc1) lib/active_record/relation/delegation.rb:46:in `map'
  activerecord (4.1.0.rc1) lib/active_record/relation/delegation.rb:46:in `map'
  /Users/tabata/.rvm/gems/ruby-2.1.0@rails41/bundlermerit (9905df1bafa0) app/models/merit/action.rb:18:in `check_unprocessed'
  /Users/tabata/.rvm/gems/ruby-2.1.0@rails41/bundlermerit (9905df1bafa0) lib/merit/controller_extensions.rb:10:in `block in included'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:440:in `instance_exec'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:440:in `block in make_lambda'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:231:in `call'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:231:in `block in halting'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:229:in `call'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:229:in `block in halting'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:166:in `call'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:166:in `call'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:166:in `call'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:86:in `call'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:86:in `run_callbacks'
  actionpack (4.1.0.rc1) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (4.1.0.rc1) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (4.1.0.rc1) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
  activesupport (4.1.0.rc1) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.1.0.rc1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.1.0.rc1) lib/active_support/notifications.rb:159:in `instrument'
  actionpack (4.1.0.rc1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (4.1.0.rc1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  activerecord (4.1.0.rc1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (4.1.0.rc1) lib/abstract_controller/base.rb:136:in `process'
  actionview (4.1.0.rc1) lib/action_view/rendering.rb:30:in `process'
  actionpack (4.1.0.rc1) lib/action_controller/metal.rb:195:in `dispatch'
  actionpack (4.1.0.rc1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  actionpack (4.1.0.rc1) lib/action_controller/metal.rb:231:in `block in action'
  actionpack (4.1.0.rc1) lib/action_dispatch/routing/route_set.rb:80:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
  actionpack (4.1.0.rc1) lib/action_dispatch/routing/route_set.rb:48:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/journey/router.rb:71:in `block in call'
  actionpack (4.1.0.rc1) lib/action_dispatch/journey/router.rb:59:in `each'
  actionpack (4.1.0.rc1) lib/action_dispatch/journey/router.rb:59:in `call'
  actionpack (4.1.0.rc1) 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:35:in `call'
  rack (1.5.2) lib/rack/head.rb:11:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  actionpack (4.1.0.rc1) 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.rc1) lib/action_dispatch/middleware/cookies.rb:551:in `call'
  activerecord (4.1.0.rc1) lib/active_record/query_cache.rb:36:in `call'
  activerecord (4.1.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
  activerecord (4.1.0.rc1) lib/active_record/migration.rb:380:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.1.0.rc1) lib/active_support/callbacks.rb:82:in `run_callbacks'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.1.0.rc1) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.1.0.rc1) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.1.0.rc1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.1.0.rc1) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.1.0.rc1) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.1.0.rc1) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.1.0.rc1) 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.rc1) lib/active_support/cache/strategy/local_cache.rb:87:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  actionpack (4.1.0.rc1) lib/action_dispatch/middleware/static.rb:64:in `call'
  rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
  railties (4.1.0.rc1) lib/rails/engine.rb:515:in `call'
  railties (4.1.0.rc1) lib/rails/application.rb:142: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/tabata/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
  /Users/tabata/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
  /Users/tabata/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'

  Rendered /Users/tabata/.rvm/gems/ruby-2.1.0@rails41/gems/actionpack-4.1.0.rc1/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.7ms)
  Rendered /Users/tabata/.rvm/gems/ruby-2.1.0@rails41/gems/actionpack-4.1.0.rc1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.6ms)
  Rendered /Users/tabata/.rvm/gems/ruby-2.1.0@rails41/gems/actionpack-4.1.0.rc1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.2ms)
  Rendered /Users/tabata/.rvm/gems/ruby-2.1.0@rails41/gems/actionpack-4.1.0.rc1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (22.5ms)
marcosgugs commented 10 years ago

The generator created the migration without .rb extension.

tute commented 10 years ago

Fixed in master, thanks for reporting!

tute commented 10 years ago

Released in 2.1.1.

marcosgugs commented 10 years ago

Thanks!!! ;)