I'm trying to add ssl to my rails 3.0.7 app using the ssl requirement gem, but when I type
include SslRequirement
into my Application controller, the app fails and I get the following error:
uninitialized constant ApplicationController::SslRequirement
Anybody seen this before?
As my comments on the question indicate, you're using gem 'sslrequirement' in your Gemfile, which is pulling down a fork of a fork of a fork of the original, none of which (the ancestors) are the (according to the original) official repository.
To fix this, you can use the following line in your Gemfile instead (note the underscore):
gem 'ssl_requirement'
Which will pull down the appropriate Gem from https://rubygems.org/gems/ssl_requirement.
Related
I've been following this tutorial, to install the ShareMeow gem in my rails app.
After adding the gem to my gem-file and the configuration variables in an initializer I run into this error.
.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/share_meow_client-0.1.3/lib/helpers/configuration.rb:18:in
`<main>': Configuration is not a module (TypeError)
After googling this error, I suspect that I'm getting this error because my rails-app already use 'Configuration' as a class somewhere else in the app?
Any ideas on how I can get around this to use this gem?
You have several options.
You can fork the gem and move Configuration into ShareMeowClient:: namespace. Then use the fork instead of the original gem with gem 'share_meow_client', github: 'you/ShareMeowClient'. You can even send this change upstream.
Alternatively, you can rename Configuration class in your app to something else (e.g. AppConfiguration) so that it doesn't clash with the one from the gem.
Or you can just copy the implementation of image_url method to your app and not use the gem at all. This is what I would prefer. The gem looks like abandonware anyway, last update is 5 years ago. It's only a few lines of code.
I have just installed rails 4.2 . I have found this tutorial for making a quick blog: https://www.reinteractive.net/posts/32-ruby-on-rails-3-2-blog-in-15-minutes-step-by-step . However, it uses rails 3.2 . I have done everything that it says up to rake db:migrate and yet, when I run the server, I just get an error page. What has changed since 3.2? what do I now have to do to do the same thing?
error:
'ExecJS::ProgramError in Posts#index'
TypeError: Object doesn't support this property or method
(in C:/Ruby193/lib/ruby/gems/1.9.1/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js.coffee)
EDIT:
On a side note, I can't even follow the official ruby on rails tutorial because when I run the server, after changing the root to root 'welcome#index' , I just get a page not found error.
Are there any tutorials for rails 4.2?
I had exactly the same ExecJS::ProgramError on Windows. The only solution that really helped was provided by KeithP here: Rails-4, ExecJS::ProgramError in Pages#welcome, i.e.,
Rollback to gem 'coffee-script-source', '1.8.0'.
There's some info here: ExecJS::RuntimeError in Users#index (RoR)
What I found when I looked into this problem was that in CoffeeScript there's a checkin here that I think broke things for Windows (under certain versions of the cscript runtime): https://github.com/jashkenas/coffeescript/blob/28c07d30cbd2add7ee762c7d532b2c9c972e441a/lib/coffee-script/parser.js
On line 563 it's doing an Object create(lexer) which fails with the error ActionView::Template::Error (TypeError: Object doesn't support this property or method.
Rolling back to CoffeeScript 1.8.0 (before this change) works around this problem. As others have stated in this answer and elsewhere, using a different runtime will workaround this problem too.
To roll back to CoffeeScript 1.8.0 add this to your gemfile:
gem 'coffee-script-source', '1.8.0'
And run these commands:
gem update 'coffee-script-source'
bundle update 'coffee-script-source'
Restart your server and it should be working.
This should solve your problem:
Add gem 'therubyracer', '~> 0.12.1' into your gemfile (or uncomment it - should be already there...)
Then run bundle install
Hope this helps.
I'm trying to install the calendar_helper gem. I included the gem in my Gemfile:
gem 'calendar_helper'
I ran bundle install and loaded fine.
Using calendar_helper (0.2.4)
0.2.4 is the newest version in GitHub, so that looks good. I'm running on Pow so I don't need to restart the server (though I tried that anyway). Adding a call to the method calendar throws an error:
undefined method `calendar'
I feel like something could be wrong with my Rails installation or something. Any ideas?
It doesn't look like version 0.2.4 is up-to-date with what's on github; it's missing the subclass of Rails::Engine necessary to load the helper. The key line on the edge source is here: https://github.com/topfunky/calendar_helper/blob/master/lib/calendar_helper.rb#L231.
You may be able to fix this by installing the gem from edge:
gem 'calendar_helper', :git => 'git://github.com/topfunky/calendar_helper.git'
Edited:
If that still isn't working, you can also try this in your ApplicationHelper:
require 'calendar_helper'
module ApplicationHelper
include CalendarHelper
end
I'm trying to upgrade the I18n backend of my application to use the database instead of the yml files for internationalization. I'm following the steps found for the I18n-active_record gem found here: https://github.com/svenfuchs/i18n-active_record.
Unfortunately, the aws-s3 gem seems to be conflicting somehow as I can't even start my server or console once I create the locale.rb initializer. Here is a summary of the steps I'm following:
gem "i18n-active_record", "~> 0.0.2"
create new file config/initializers/locale.rb
inside locale.rb
I18n.backend = I18n::Backend::Database.new
restart localhost server to load initializer
Error Message
/Users/user_name/.rvm/gems/ree-1.8.7-2010.02#app/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing': uninitialized constant I18n::Backend::Database (NameError)
...(Several more lines)
Any help or insight would be appreciated!
Great question and great discussion. The answer is contained in a combination of the comments up above, but for those of you who are upgrading to a Rails 3 application, this is a summary of the steps I had to take.
Add this to your Gemfile:
gem 'i18n-active_record', :require => 'i18n/active_record'
Add this to a new config file config/initializers/locale.rb
require 'i18n/backend/active_record'
I18n.backend = I18n::Backend::ActiveRecord.new
Take out any code in application.rb that was previously initializing the record store. This clears the missing content errors. Full instructions are on the Github repo for this backend module which was removed from the core I18n: https://github.com/svenfuchs/i18n-active_record
Although the readme in github says so, I don't think the Database constant is actually defined by the gem. Try
I18n.backend = I18n::Backend::ActiveRecord.new
I've added the delayed_job gem to my gemfile and installed correctly but when I try to run the following line:
Delayed::Job.enqueue do_it(), 0, 1.minutes.from_now.getutc
I get the error 'uninitialized constant Delayed::Job'
Can somebody explain what i need to do here? I've tried running 'rake jobs:work' beforehand but it also returns the 'uninitialized constant Delayed::Job' error. Additionally, I've added "require 'delayed_job'" to the file (application.rb) without much luck.
If you've upgraded to delayed_job version >=3 you'll need to add this (presuming you're using ActiveRecord):
# Gemfile
gem 'delayed_job_active_record'
Did you follow the installation instructions on the README file? https://github.com/collectiveidea/delayed_job
Add this to your gemfile:
gem 'delayed_job_active_record'
and then run this at the console:
$ rails generate delayed_job:active_record
$ rake db:migrate
You need to create the delayed jobs table in the database (this assumes you're using active record).
For Rails 3, all you need to do is include it in the gemfile, run that code above to create the table and migrate the database, then restart your server and go!
I'm using delayed job within an engine (so the gem is specified in a .gemspec rather than Gemfile) and was getting the same error. I found that I could solve the problem by using:
require 'delayed_job_active_record' # fixes problem
rather than
require 'delayed_job' # doesn't
Just in case, if this is still unanswered, check the below link
http://www.pipetodevnull.com/past/2010/4/14/uninitialized_constant_delayedjob/
edit: Alternative, just upgrade to the latest version - 2.1
i was struggling a while back with the same problem. i was following ryan bates screencast on delayed_job and got the same error 'uninitialized constant Delayed::Job'. In the screencast ryan creates a file called mailing_job.rb(located under lib folder) with the delayed_job perform method inside, which allows you to use the enqueue method. After doing some research i found that rails 3 does not automatically load the lib folder files into your app.(not entirely sure)
Try this
In your controller where you use this:
"Delayed::Job.enqueue do_it(), 0, 1.minutes.from_now.getutc"
Try to require the file like this.
require 'mailing_job'
class AssetsController < ApplicationController
def some_method
Delayed::Job.enqueue do_it(), 0, 1.minutes.from_now.getutc
end
end
Version change possibility : if you jump from the 2.1.x to the 3.x version of the gem via a non locked down bundle, you may have a similar issue.