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"
Related
I am trying to setup and use omniauth-ebay-oauth (https://github.com/evilmartians/omniauth-ebay-oauth) gem to use eBay rest APIs in my app without success.
I set up the required environment variables and run the example code but get a message saying "Sinatra doesn’t know this ditty.". It does not recognise the '/auth/ebay' route, not sure if I have to declare that route myself nor what to put in it if I do. I'm new to ruby and Sinatra so do apologise if this is just something silly and obvious that I'm missing.
require 'omniauth-ebay-oauth'
use Rack::Session::Cookie
use OmniAuth::Builder do
provider :ebay_oauth, ENV['EBAY_CLIENT_ID'], ENV['EBAY_CLIENT_SECRET'],
callback_url: ENV['EBAY_RU_NAME'], name: 'ebay'
end
get '/' do
redirect '/auth/ebay'
end
get '/auth/ebay/callback' do
"Hello, #{request.env['omniauth.auth'].dig('info', 'name')}"
end
I appreciate any help and insight in getting this working. I've googled everywhere and asking here as my last resort.
I opened an issue on the GitHub repository and the gem creator replied in 3 hours. Totally life saver. I will post the solution here to help others.
It is because of security settings of OmniAuth 2.x.
Add the following line at the top, after requires:
OmniAuth.config.allowed_request_methods += %i[get]
This worked like a charm and I can now move forwards with the project.
I'm running Rails 4.2.0.beta and am having a weird issue; instead of the usual Rail’s page displaying exceptions in development mode, like so:
I get the following:
This page appears with any exception.
I have double checked that I'm under development mode and that 'consider_all_requests_local' is set to true in config/environments/development.rb.
I noticed I'm receiving the following error when I hit an exception
" ERROR Rack::Lint::LintError: Response body was given for HEAD request, but should be empty
/Users/Rali/.rbenv/versions/2.2.0-dev/lib/ruby/gems/2.2.0/gems/rack-1.6.0.beta/lib/rack/lint.rb:20:in `assert'"
I assume it's somehow related.. Any ideas?
Sorry for digging out a month-old question but if there is anyone with same issue (like me), though with version 4.2.0.rc1 I fixed it by removing gem 'web-console' from Gemfile which is by default added when generating new application.
Removing gem 'web-console' also solved this issue for me in Rails 5.1, for anyone stumbling into this issue 4 years later...
My goal is to build a simple custom guard with Guard. The gem install and bundler install for my app went fine. My Guardfile contains:
notification :growl
guard 'eyeball' do
watch %r{^app/(.*)}
watch %r{^config/(.*)}
watch %r{^lib/(.*)}
end
Ok, next, I need to tell Guard what to do when a match happens. But I don't know where to do that. (In this case, I want to watch my application for changes and run some arbitrary code. Assume that there isn't a guard available for what I want. I want to learn how to do it myself.)
In true 'blunder and see what errors pop up next' style, when I run guard I get this error message:
ERROR: Could not load 'guard/eyeball' or find class Guard::Eyeball
ERROR: cannot load such file -- guard/eyeball
ERROR: Invalid Guardfile, original error is:
undefined method `new' for nil:NilClass
ERROR: No guards found in Guardfile, please add at least one.
Guard uses Growl to send notifications.
Guard is now watching at '/Users/my-user-name/dev/my-project-name'
So, that gives me a hint that I need to create a guard/eyeball.rb file. Maybe? But how was I supposed to know this from the documentation?
I've read (several times) the very detailed and useful Guard README but haven't found a good simple example that shows someone how to do 'just the basics' of writing your own guard. Unexpectedly, RailsCasts didn't really answer my question either: see RailsCast #264 Guard.
Did I overlook something in the Guard README? Can you help or point to a good example? Thanks!
Sweet! I just found a Wiki page on the Guard wiki titled Create a guard that answers my questions. It was not mentioned in the README, so I had to dig for it.
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!
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