GithubHelp home page GithubHelp logo

Comments (17)

tute avatar tute commented on August 18, 2024

Hi and thanks for your feedback. It is indeed weird.

  • Are you using ActiveRecord or other ORM?
  • Could you please paste your config/initializers/merit.rb?
  • I just commited something that may be related. Could you please test your app with the repo's version? gem 'merit', git: 'git://github.com/tute/merit.git' If it works I may release a new minor version so you can update.

from merit.

joncslee avatar joncslee commented on August 18, 2024

Thanks for the quick response!

  • Yes, I am using ActiveRecord
  • Here are my merit.rb contents:
# Use this hook to configure merit parameters
Merit.setup do |config|
  # Check rules on each request or in background
  config.checks_on_each_request = true

  # Define ORM. Could be :active_record (default) and :mongo_mapper and :mongoid
  config.orm = :active_record

  # Define :user_model_name. This model will be used to grand badge if no :to option is given. Default is "User".
  config.user_model_name = "User"

  # Define :current_user_method. Similar to previous option. It will be used to retrieve :user_model_name object if no :to option is given. Default is "current_#{user_model_name.downcase}".
  config.current_user_method = "current_user"
end

# Create application badges (uses https://github.com/norman/ambry)

# Chatterbox
Badge.create!({
  :id => 1,
  :name => 'Chatterbox'
})

# Short N Sweet
Badge.create!({
  :id => 2,
  :name => 'Short N Sweet'
})

# Overachiever
Badge.create!({
  :id => 3,
  :name => 'Overachiever'
})
  • I updated the Gemfile to use your repo's version and then tested my app's flow. Now, where I saw the error before, I now see this new error:
undefined method `create' for Merit::Action:Class

Full stack trace:

/Users/jon/.rvm/gems/ruby-1.9.3-p327@gratefuleaf/bundler/gems/merit-a91a4c57f2ce/lib/merit/controller_extensions.rb:18:in `log_merit_action'
/Users/jon/.rvm/gems/ruby-1.9.3-p327@gratefuleaf/bundler/gems/merit-a91a4c57f2ce/lib/merit/controller_extensions.rb:9:in `block in included'
activesupport (3.2.9) lib/active_support/callbacks.rb:438:in `_run__2674818574677215744__process_action__2363464559761458068__callbacks'
activesupport (3.2.9) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.9) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.9) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.9) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.9) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.9) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.9) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.9) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.9) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.9) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.9) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.9) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.9) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.9) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.9) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.9) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.9) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.9) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.9) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.9) 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.9) lib/action_dispatch/routing/route_set.rb:601:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:35:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.9) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.9) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.9) lib/active_support/callbacks.rb:405:in `_run__300673115842476378__call__2099595980555344963__callbacks'
activesupport (3.2.9) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.9) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.9) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.9) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.9) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.9) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.9) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.9) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.9) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.9) lib/rails/engine.rb:479:in `call'
railties (3.2.9) lib/rails/application.rb:223:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.9) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/Users/jon/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/jon/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/jon/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

from merit.

joncslee avatar joncslee commented on August 18, 2024

Hey, just wanted to let you know that I solved my issue, so to speak. Instead of placing my rules for point creation in point_rules.rb, I'm simply manually assigning points to the user in the create action of my controller itself. I know that this isn't a "solution" but merely a work-around. At the same time, I'm recognizing that my situation is probably an edge case in this scenario. Anyways, the app works as it should now, and I hope this feedback helped you in some way with this obscure bug (which is likely just some random bug on my own end, not yours). Let me know if you want any more feedback regarding the bug. I will be integrating the badges part of your plugin into my app later, and if a similar issue crops up, I'll let you know. Thanks again for this awesome plugin!

from merit.

tute avatar tute commented on August 18, 2024

Hi! I can't reproduce this bug, so if you could send me a zipped app (either yours or one you can build that triggers this behavior) it would be great. Thanks for your feedback.

from merit.

sabernar avatar sabernar commented on August 18, 2024

I've been receiving this same error. I also get:

NoMethodError (undefined method `current_user' for #ProjectsController:0x007fdada4e6670):

from merit.

tute avatar tute commented on August 18, 2024

Hi @sabernar. current_user is meant to have a user in your application. It's not related to merit.
Can you please send me a zipped version of your app so I can test this bug, which I can't reproduce?
Thank you.

from merit.

arthurccube avatar arthurccube commented on August 18, 2024

I found the "undefined method `attr_accessible' for Merit::Action:Class" bugs happened whenever I changed the related model and save.

it disappear once I restart the server.

from merit.

gjones avatar gjones commented on August 18, 2024

@joncslee, can you please post an example of your controller workaround? I'm facing the same error and would be interested to know how you implemented it. Thanks

undefined method `create' for Merit::Action:Class

from merit.

arthurccube avatar arthurccube commented on August 18, 2024

Hi @joncslee
I am not sure if it is an workaround, but I just restart my project when i found the problem.

However, I got some facts for the bugs that should be useful for ppl who wanna fix it.

  1. I am using another framework - SocialStream, in which the user model is in the plugin (it can created problem during install)
  2. I am using inherited_resources
  3. Errors only found after I updated a model

from merit.

joncslee avatar joncslee commented on August 18, 2024

@gjones, my workaround was as follow: where before I awarded points in app/models/merit/point_rules.rb like this:

score 2, :on => 'posts#create' do |post|
  post.content? && !post.photo_file_name?
end

score 3, :on => 'posts#create' do |post|
  post.content? && post.photo_file_name?
end

Now, I simply award the points manually in the actual create action of the PostsController like so:

if @post.save
  # add points for successful creation!
  if @post.photo_file_name
    current_user.add_points(3)
  else
    current_user.add_points(2)
  end
end

@arthurccube, when you restarted your server when you encounter the problem, does it fix it for good? Or does it just fix it until you update the code again, at which point you need to restart again?

@tute, sorry for the radio silence lately, work has been crazy hectic. I will try to duplicate the problem on a stripped version of my app first chance I get and zip it up over to you!

from merit.

tute avatar tute commented on August 18, 2024

I'll appreciate it @joncslee. Thanks for your help!

from merit.

arthurccube avatar arthurccube commented on August 18, 2024

Hi @joncslee
Yes, the problem just go away after I restart.

But it continuously happened when I update the model afterwards.

Arthur

from merit.

joncslee avatar joncslee commented on August 18, 2024

Hi @tute I was able to reproduce the bug in a barebones app and zip it up. It's just a basic post creation app with user authentication using authlogic. I am awarding points to the user upon post creation. It works until I make an edit to a controller or model file, at which point I trigger our elusive bug. How would you like me to send you the zipped app?

from merit.

tute avatar tute commented on August 18, 2024

Awesome, thank you @joncslee! Please send the zip at MY-EMAIL.

from merit.

tute avatar tute commented on August 18, 2024

Thank you very much for your help, @joncslee!

from merit.

joncslee avatar joncslee commented on August 18, 2024

Awesome, works great, thanks! I'm glad I could help :)

from merit.

gjones avatar gjones commented on August 18, 2024

Thanks for your work!

from merit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.