Hopefully I'm just missing something simple. I am using mongomapper in a rails 3 app and it works beautifully. I needed to share it with another app and pushed it out to a gem, which also works great from both rails apps. However, when I try to add rspec tests to the gem I am getting the following error:
/Users/dane/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.2/lib/rspec/core/backward_compatibility.rb:20:in `const_missing': uninitialized constant User::MongoMapper (NameError)
I am adding a really simple test for my User model.
Thanks!
Related
I am using my rake console pry session to test out a class I have created for a CLI application I am making. Everytime I type "City.new" I expect to see nil attributes as instructed but I get a:
City.new
NameError: uninitialized constant City
What are common reasons for getting this error if I defined my class in another file. How can I fix this issue?
Thanks so much
I came across the same issue, I had not generated the controller for City model. Try that to see if will work
I used padrino-0.14.1.1 and activesupport-5.1.1 in combination and I generate padrino admin app. When I display the login page (/admin/sessions/new) the following error occurred and become 500 error page.
DEBUG - TEMPLATE (0.0007s) /sessions/new
2017-11-07 20:23:01 - NoMethodError - undefined method `humanize' for "login.title":String:
/Path/to/app/'vendor/bundle' /ruby/2.3.0/gems/padrino-admin-0.14.1.1/lib/padrino-admin/helpers/view_helpers.rb:43:in `padrino_admin_translate'
...
I think it is not a bug of Padrino, because I cannot find same problems in the Internet. And I add the following require to the beginning of view_helpers.rb provisionaly.
require 'active_support'
require 'active_support/core_ext/string'
However, I think it is not good to edit Padrino's files because of my application problem. Please let me know if you have any other good countermeasures.
I got the answer of this question from Padrino maintainer on Github.
And I tried the suggestion in the answer, that worked well.
The answer is following.
--
Looks like a bug due to the ongoing effort to remove the ActiveSupport dependency from Padrino.
You don't need to update view_helpers.rb - creating a file in config/initializers should be sufficient as a temporary stop-gap until the bug is fixed.
# config/initializers/extra_requires.rb
require "active_support"
require "active_support/core_ext/string"
I've been getting an issue where when using Padrino and paperclip whenever I try to upload an image I get the error
Paperclip::AdapterRegistry::NoHandlerError
What's going wrong?
For those wondering, the multipart form thing mentioned in many other posts is also true. See Other SO posts
All of those relate to Rails and specifically if you are using Padrino or another rack based application, you need to add one more thing or else it won't work
The exception being thrown was due to the uploaded file being represented by a Hash (Rack converts it into a Hash), and that Paperclip does not provide an adapter for this Rack specific Hash out of the box.
You need to install this gem:
gem 'paperclip-rack', require: 'paperclip/rack'
I've been trying to tackle this all morning. Locally, this setup works just fine. I am not using the redactor-rails gem because this is a rails 4 app and it doesn't support it. I have moved the redactor.css and redactor.js calls from the active_admin initializer file to be required in my actice_admin.js.coffee and active_admin.css files because on Heroku, it could not find the path. Now, when firing up the page that should be displaying redactor, I get has no method 'redactor' in the console.
I'm at a loss. I've read up on precompiling assets and the how the pipeline works, but it doesn't seem like I'm doing anything out of the ordinary here.
So how can I deploy to Heroku without this error?
Ok, so I seemed to have disregarded an important task. After thinking about precompilation a bit more I remembered I had been told to run
RAILS_ENV=production bundle exec rake assets:precompile
before. After running that again, it precompiled the active_admin.css and active_admin.js.coffee files which had the new require's in it. Viola!
Hope this helps someone else in the future.
I'm working on a ruby app that updates a twitter account using 'twitter' gem. It's working fine locally (as usual :) ). But when I deploy it on heroku it seems the gem is not properly installed or something lile that as I got the following error:
NameError: uninitialized constant Twitter::OAuth
My code is very simple:
oauth = Twitter::OAuth.new(consumer_token, consumer_secret)
oauth.authorize_from_access(access_token, access_secret)
client = Twitter::Base.new(oauth)
client.update("Updating my status from twitter gem. GREAT!")
Is there a problem with this particular gem ?
Thanks a lot for your help.
Luc
Have you created a .gems file and put twitter in it?
Depending on which heroku 'stack' you are on, you may need to do that instead of a bundler Gemfile. You can change your stack for one that uses bundler by doing this:
heroku stack:migrate bamboo-ree-1.8.7
Which makes bundler available (I think).
That is a common message that usually implies that you have a discrepancy between your local gems and the gems in heroku. If you are not using Bundler yet, you should. You will end un writing a very simple Gemfile that will tell Heroku (or any other entity using your code) which gems and versions you require.
http://gembundler.com/
I would suggest that you should use the heroku addon called 'apigee', ut makes twitter on heroku simple:
http://addons.heroku.com/apigee
I just got a sinatra app talking to Twitter through Heroku/Apigee, my rate limit went from 300 calls per hour to 20,000 calls per hour. Here's a step by step on what to do:
http://geeks.aretotally.in/mind/2011/1/8/increasing-api-limits-on-a-sinatra-twitter-app-with-twitter_.html
I am really a Java developer just playing around with Sinatra but let me know if I can help in anything.
Felipe