Previously I haven't got such a problem with Rails 2.3.2 installation. Somebody have any suggestions how can I fix that?
`$ ruby script/server
=> Booting WEBrick
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
/home/thesis/.rvm/gems/ruby-1.8.7-p334#my_app/gems/rails-2.3.2/lib/rails/gem_dependency.rb:99:in 'requirement': undefined local variable or method 'version_requirements' for # (NameError)
from /home/thesis/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems.rb:254:in 'activate'
from /home/thesis/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems.rb:1204:in 'gem'
from /home/thesis/.rvm/gems/ruby-1.8.7-p334#my_app/gems/rails-2.3.2/lib/rails/gem_dependency.rb:57:in 'add_load_paths'
from /home/thesis/.rvm/gems/ruby-1.8.7-p334#my_app/gems/rails-2.3.2/lib/initializer.rb:299:in 'add_gem_load_paths'
from /home/thesis/.rvm/gems/ruby-1.8.7-p334#my_app/gems/rails-2.3.2/lib/initializer.rb:299:in 'each'
from /home/thesis/.rvm/gems/ruby-1.8.7-p334#my_app/gems/rails-2.3.2/lib/initializer.rb:299:in 'add_gem_load_paths'
from /home/thesis/.rvm/gems/ruby-1.8.7-p334#my_app/gems/rails-2.3.2/lib/initializer.rb:132:in 'process'
from /home/thesis/.rvm/gems/ruby-1.8.7-p334#my_app/gems/rails-2.3.2/lib/initializer.rb:113:in 'send'
from /home/thesis/.rvm/gems/ruby-1.8.7-p334#my_app/gems/rails-2.3.2/lib/initializer.rb:113:in 'run'
from /home/thesis/development/tt/my_app/config/environment.rb:15
from /home/thesis/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in 'gem_original_require'
from /home/thesis/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in 'require'
from /home/thesis/.rvm/gems/ruby-1.8.7-p334#my_app/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in 'require'
from /home/thesis/.rvm/gems/ruby-1.8.7-p334#my_app/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in 'new_constants_in'
from /home/thesis/.rvm/gems/ruby-1.8.7-p334#my_app/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in 'require'
from /home/thesis/.rvm/gems/ruby-1.8.7-p334#my_app/gems/rails-2.3.2/lib/commands/server.rb:84
from /home/thesis/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in 'gem_original_require'
from /home/thesis/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in 'require'
from script/server:3`
put below code in your environment.rb. it might be solved your problem
if Gem::VERSION >= "1.3.6"
module Rails
class GemDependency
def requirement
r = super
(r == Gem::Requirement.default) ? nil : r
end
end
end
end
Related
I enabled Refinery Search and Refinery Blog extensions in Gemfile and run rake db:migrate, rake db:seed.
And per Refinery Search instructions file, added the following to config/application.rb
config.to_prepare do
Refinery.searchable_models = [Refinery::Blog]
end
And also created app/decorators/models/refinery/blog_decorator.rb with
Refinery::Blog.class_eval do
acts_as_indexed :fields => [:title, :body, :custom_teaser]
end
Above example is from: http://refinerycms.com/guides/extending-model
But when I try to run rails c or rails s, there is an error:
=> Ctrl-C to shutdown server
Exiting
/home/bismailov/Desktop/my_docs/Inbox/ror/maqolarefinery/app/decorators/models/refinery/blog_decorator.rb:2:in `block in <top (required)>':
undefined method `acts_as_indexed' for Refinery::Blog:Module (NoMethodError)
from /home/bismailov/Desktop/my_docs/Inbox/ror/maqolarefinery/app/decorators/models/refinery/blog_decorator.rb:1:in `class_eval'
What could I be missing here? Thank you a lot!
Actually Refinery::Blog is a module not a model. Ideally you should use Refinery::Blog::Post.
I've installed ember-appkit-rails, but when I do rails g ember:bootstrap I get the following error can anyone help?
/home/ltsimps/.rvm/ruby-1.9.3-p392/gems/ember-appkit-rails-0.3.0/lib/ember/appkit/rails/sprockets/context.rb:10:in '': undefined method prepend' for Sprockets::Context:Class (NoMethodError)
from /home/ltsimps/.rvm/ruby-1.9.3-p392/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in 'require'
from /home/ltsimps/.rvm/ruby-1.9.3-p392/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228 'block in require'
from /home/ltsimps/.rvm/ruby-1.9.3-p392/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213 'load_dependency'
from /home/ltsimps/.rvm/ruby-1.9.3-p392/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228 'require'
from /home/ltsimps/.rvm/ruby-1.9.3-p392/gems/ember-appkit-rails-0.3.0/lib/ember/appkit/rails/sprockets.rb:3:in ....
I just changed to ruby 2.0 and that fixed the problem.
I'm trying to create an xml runner to make a result report of Rails unit testing. Here is a code I have:
require 'test/unit'
require 'test/unit/ui/console/testrunner'
class FastFailRunner < Test::Unit::UI::Console::TestRunner
def add_fault(fault)
#faults << fault
nl
output("%3d) %s" % [#faults.length, fault.long_display])
output("--")
#already_outputted = true
end
def finished(elapsed_time)
nl
output("Finished in #{elapsed_time} seconds.")
nl
output(#result)
end
end
Test::Unit::AutoRunner::RUNNERS[:fastfail] = proc do |r|
FastFailRunner
end
When I run it as TESTOPTS="/home/alex/RubymineProjects/app2/test/unit/runner.rb --runner=xml" rake test
... I get an error (pretty weird error)
/home/alex/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in `const_missing': uninitialized constant Test::Unit::UI::XML (NameError)
from /home/alex/.rvm/gems/ruby-1.9.3-p194/gems/test-unit-2.5.2/lib/test/unit/runner/xml.rb:5:in `block in <module:Unit>'
from /home/alex/.rvm/gems/ruby-1.9.3-p194/gems/test-unit-2.5.2/lib/test/unit/autorunner.rb:389:in `[]'
from /home/alex/.rvm/gems/ruby-1.9.3-p194/gems/test-unit-2.5.2/lib/test/unit/autorunner.rb:389:in `run'
from /home/alex/.rvm/gems/ruby-1.9.3-p194/gems/test-unit-2.5.2/lib/test/unit/autorunner.rb:58:in `run'
from /home/alex/.rvm/gems/ruby-1.9.3-p194/gems/test-unit-2.5.2/lib/test/unit.rb:501:in `block in <top (required)>'
gem install minitest
/home/alex/.rvm/gems/ruby-1.9.3-p194/gems/test-unit-2.5.2/lib/test/unit/runner/xml.rb:5:in `block in <module:Unit>': uninitialized constant Test::Unit::UI::XML (NameError)
from /home/alex/.rvm/gems/ruby-1.9.3-p194/gems/test-unit-2.5.2/lib/test/unit/autorunner.rb:389:in `[]'
from /home/alex/.rvm/gems/ruby-1.9.3-p194/gems/test-unit-2.5.2/lib/test/unit/autorunner.rb:389:in `run'
from /home/alex/.rvm/gems/ruby-1.9.3-p194/gems/test-unit-2.5.2/lib/test/unit/autorunner.rb:58:in `run'
from /home/alex/.rvm/gems/ruby-1.9.3-p194/gems/test-unit-2.5.2/lib/test/unit.rb:501:in `block in <top (required)>'
Errors running test:units! #<RuntimeError: Command failed with status (1): [/home/alex/.rvm/rubies/ruby-1.9.3-p194/bin...]>
Errors running test:functionals! #<RuntimeError: Command failed with status (1): [/home/alex/.rvm/rubies/ruby-1.9.3-p194/bin...]>
I tried to require test/unit/ui/xml/testrunner.rb but no luck.
Any thoughts?
If you are in Ruby 1.8.7 you can say:
require 'test/unit/ui/console/testrunner'
p Test::Unit::UI::Console::TestRunner # => no problem
(There is no such file as test/unit/ui/xml/testrunner.rb so I'm not sure what you were up to there.)
Look in the docs in test/unit.rb, there's actually sample code showing you how to do this require: http://www.ruby-doc.org/stdlib-1.8.7/libdoc/test/unit/rdoc/Test/Unit.html.
However, the problem is that you are in Ruby 1.9.3. There is no /test/unit in Ruby 1.9.3! Well, there is, but it's just a compatibility layer for basic tests; there is certainly no test/unit/ui/console/testrunner, and no module/class Test::Unit::UI::Console::TestRunner.
Instead, there's minitest. You can read the docs on minitest to see how to make a test runner. http://docs.seattlerb.org/minitest/
One thing to consider is that Test::Unit was included in the default Ruby 1.8.7 installation. If you want to use it in with a later version of Ruby then go ahead and install it as a gem.
sudo gem install test-unit
http://test-unit.rubyforge.org/
Does anyone know why this callback method would work in Rails 2.3.x / Ruby 1.8.7 but not in Rails 3.0.x / Ruby 1.9.2?
Works in Rails 2.3.x / Ruby 1.8.7:
class Post < ActiveRecord::Base
after_create :destroy_old_posts
acts_as_taggable
# ...
protected
def destroy_old_posts
self.tag_list.each do |tag|
posts = Post.find_tagged_with(tag, :order => 'updated_at DESC')
posts[19..-1].each {|p| p.destroy } if posts.size >= 20
end
end
end
But with 3.0.x / Ruby 1.9.2 I receive the following error upon creating a post:
undefined method `find_tagged_with' for #<Class:0x00000002943048>
app/models/post.rb:30:in `block in destroy_old_posts'
app/models/post.rb:29:in `each'
app/models/post.rb:29:in `destroy_old_posts'
app/controllers/posts_controller.rb:29:in `block in create'
app/controllers/posts_controller.rb:28:in `create'
I'm using acts-as-taggable-on 2.0.6. Thank you for reading my question.
I believe the correct usage is Post.tagged_with
If a project is running Rails 2.2.2, and it uses controller.helper and the helper is not defined, then how can it be solved? (this is for the Facebooker2 gem http://github.com/mmangino/facebooker2)
details:
error shown:
=> Rails 2.2.2 application starting on http://0.0.0.0:3000
Exiting
/Library/
Ruby/
Gems/1.8/gems/facebooker2-0.0.5/lib/facebooker2/rails/controller.rb:8:
in `included': undefined method `helper' for Object:Class (NoMethodError)
The code is: error line is line 8:
controller.helper Facebooker2::Rails::Helpers
in the following code:
module Facebooker2
module Rails
module Controller
def self.included(controller)
controller.helper Facebooker2::Rails::Helpers
controller.helper_method :current_facebook_user
controller.helper_method :current_facebook_client
controller.helper_method :facebook_params
end