When creating a new Rails project using:
rails sample
Then creating a model using:
script/generate model person first_name:string last_name:string
Everything is fine. However, if I add any gems to my environment.rb:
config.gem "authlogic"
And run the same generator, I get the following:
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning:
Gem::Dependency#version_requirements
is deprecated and will be removed on
or after August 2010.
The warning just recently appeared (I think), but I would like to fix it if possible. Any hints or similar experiences?
Thanks.
did you try:
rake gems:install
Btw. If you are using rubygems 1.3.6 then you get this deprecation warning. Previous versions never gave a warning. Also i suggest installing any gem using the command line rather than adding it in the environment.rb file. If the gem(s) you have added in the file is/are not installed, then the generator or any rake task will simply not run. Its a minor bug.
Here is an article that describes a way to prevent the warning:
http://www.mattvsworld.com/blog/2010/03/version_requirements-deprecated-warning-in-rails/
Its no big deal though. Just install gems the normal way and don't add any to your environment.rb file. You'll never get the deprecation warning.
This may be irrelevant as it is rails 3.0 but the answer you are looking for is in this article:
http://omgbloglol.com/post/353978923/the-path-to-rails-3-approaching-the-upgrade
down by the section titled "config.gem is dead, long live bundler", although the article does explain some new things.
You may want to consider upgrading to rails 3.0 and when you do, you will be using the Gemfile inside your application. in here, you will want to include the line:
gem 'authlogic'
and then on the command line, run
sudo bundle install
After that, all should be set :)
Check https://gist.github.com/807008 they suggest to downgrade and upgrade again rubygems.
Worked for me...
Putting these lines in your config/environment.rb between your bootstrap and your initializer will remove the deprecation warning:
if Gem::VERSION >= "1.3.6"
module Rails
class GemDependency
def requirement
super == Gem::Requirement.default ? nil : super
end
end
end
end
Related
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 am having problem in full_calendar table builder.and i am using rails 4.I have used following command . **rails plugin install git://github.com/p8/table_builder.git
** I got error like **/usr/local/rvm/gems/ruby-2.0.0-p247#ruby2/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require': cannot load such file -- rails/commands/plugin (LoadError)
**
And My view look like
It won't showing in table format. Please help me....
Use the gem instead of the plugin. Also I don't think that repository is active anymore, there is an alternative listed on the readme; and it doesn't look like table_builder has been updated for rails 4 so you might encounter other issues.
This is the updated repo: https://github.com/watu/table_builder
Add it to your gemfile & run bundle install:
gem "watu_table_builder", :require => "table_builder"
If you're using a tutorial for an older version of rails note that there are some things that will bite you -- (plugins, strong paramenters, Model.all, etc)
I am on hour 12 of programming, so i might be overlooking something simple, but any suggestions on this issue?
in my app_helper i added a module for a redcarpet filter with haml
module Haml::Filters::Redcarpet
include Haml::Filters::Base
include ActionView::Helpers::TagHelper
def render(text)
options = [:autolink, :smart, :hard_wrap, :no_intraemphasis]
content_tag(:div, Redcarpet.new(text.to_s, *options).to_html.html_safe, :class => "markup" )
end
end
works great in development. but in production, it's throwing
[ !EXCEPTION! ] NoMethodError: undefined method 'content_tag' for Haml::Filters::Redcarpet:Module
why would that be? or what can i check? i even ran the console on production and was able to include TagHelper and use those methods. puzzled...
My guess is that you have different versions of one or more gems on your production box from your dev environment. Do "gem list" in both and add the results to your original post.
The best way to avoid this problem is to use the Ruby Version Manager (RVM) and the 'bundler' gem: you can create a gemset specific to your project and thus ensure that the gems are exactly the same for both versions (prod & dev) of the project.
rvm: https://rvm.io
bundler: http://gembundler.com/
Oh - and if you look down your stack trace you will probably see a reference to the gem that sets up the haml/redcarpet stuff, this is probably the culprit, ie has a different version.
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.
I've been trying to use HTTParty in my rails code
sudo gem install httparty
From the command line I can now successfully do
httparty "http://twitter.com/statuses/public_timeline.json"
When I try this in my rails app
require 'rubygems'
require 'httparty'
class FooController < ApplicationController
include HTTParty
def bar
blah = HTTParty.get("http://twitter.com/statuses/public_timeline.json")
end
end
I get the error message "no such file to load -- httparty"
I suspect there is something wrong with my environment?
You don't need to do 'include HTTParty' inside the Controller. Just remove that and it should work. I just tested it and it worked for me. If this doesn't work for you, you should add the gem to your environment.
Usually if you use a gem inside your Rails application, you should add the following to environment.rb:
config.gem "httparty"
The gem will be available in the application now and you don't need to add 'require' inside the Controller. Also, you don't need to require RubyGems inside a Controller.
When you use Rails 3, you need to put the following inside the Gemfile:
gem "httparty"
I hope it works for you. :)
The problem is, if you load a new gem, you have to restart the server even if you are in development.
I had this same error. I tried moving the require HTTParty all over, but found, all I needed to do was restart the rails server In the end I did not need to 'require HTTParty' nor 'include' it. It just needed to be loaded into rails.
1)include the httpary in your gemfile
open your gem file then add
gem 'httparty','YOUR VERSION NUMBER'
2) run bundle install in your command prompt of the app file
3) restart the server
Ran into the same problem. Then I switched from Ruby 1.8.7 to Ruby 1.9.2 and all errors varnished into thin air.
(Yes, it first took me quite some hours to come up with the possibility that the Ruby version might be the problem. Configured a secundairy server to avoid possible conflicts with 2 ruby versions, and after way to many hours I got my RoR stack up and running. And the first test with httparty (based on the example on top) worked out of the box! Finally can sleep RESTfully again :-)
I run into the same error whilst reviewing a project from a student, I change the name of the Gem from uppercase to lowercase then run bundle install. I then went ahead to change the format in which they were being imported from
require 'HTTParty' to require 'httparty' and boom it worked