`method_missing': undefined method `paginates_per' for #<Class:…> - ruby-on-rails-3

My rails application is generating the following error (when running rails generators, or launching WEBrick):
/home/lachlan/.gem/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/dynamic_matchers.rb:50:in `method_missing': undefined method `paginates_per' for #<Class:0x0000000293d7d8> (NoMethodError)
from /home/lachlan/.gem/ruby/1.9.1/gems/rich-1.3.1/app/models/rich/rich_file.rb:13:in `<class:RichFile>'
from /home/lachlan/.gem/ruby/1.9.1/gems/rich-1.3.1/app/models/rich/rich_file.rb:6:in `<module:Rich>'
from /home/lachlan/.gem/ruby/1.9.1/gems/rich-1.3.1/app/models/rich/rich_file.rb:5:in `<top (required)>'
I am using the following gems, that I assume may be involved in the error:
gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
gem 'less-rails'
gem 'twitter-bootstrap-rails'
gem 'jquery-rails'
gem 'rails_admin'
gem 'rich'
gem 'kaminari'
I have run rake db:migrate.
Any ideas as to what could be causing this?

I managed to work out what was causing the problem. I was excluding 'Rich::RichFile' in the rails_admin configuration. Removing this line solved the problem.

Related

Rails 3 + Heroku: cannot load such file -- test/unit/testcase (LoadError)

I'm having the following error when running the console in heroku (heroku run console...). The application is running without problems, but I seem to be unable to run the console because of this and in development I'm not having this issue.
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- test/unit/testcase (LoadError)
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/test_case.rb:1:in `<top (required)>'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/console/app.rb:2:in `<top (required)>'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:304:in `initialize_console'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:152:in `load_console'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands/console.rb:27:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands/console.rb:8:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
This is my Gemfile:
source 'http://rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.9'
gem 'oauth', '~> 0.4.4'
gem 'twitter', '~> 1.4.1'
gem 'sendgrid'
gem 'koala'
gem 'therubyracer', '0.10.2'
gem 'execjs'
# Rails 3.1 - Asset Pipeline
gem 'json'
group :assets do
gem 'sass-rails', " >= 3.2.3"
gem 'coffee-rails', ">= 3.2.1"
gem 'uglifier', '>= 1.0.3'
gem 'bootstrap-sass'
end
gem 'coffee-script'
gem 'jquery-rails'
gem "fog"
gem 'bootstrap-wysihtml5-rails', '0.3.1.10'
group :production do
gem "heroku"
gem 'pg', '0.13'
gem 'newrelic_rpm'
gem 'newrelic_api'
end
group :test do
gem 'email_spec'
gem "cucumber-rails"
gem "rspec-rails"
gem "capybara"
gem 'culerity'
gem "selenium-webdriver"
gem "database_cleaner"
gem 'factory_girl_rails'
end
group :development, :grades, :test do
gem "launchy"
gem "mysql2"
gem "letter_opener"
gem "pry"
gem "rails-erd"
end
gem "airbrake"
gem "authlogic"
gem 'awesome_print'
gem 'cancan'
gem 'dalli'
#gem "oink"
gem 'validates_timeliness', '~> 3.0.2'
gem 'hpricot'
gem "ruby_parser"
gem "prawn_rails"
gem "thin"
gem "nested_form", :git => "git://github.com/ryanb/nested_form.git"
gem "meta_search"
gem "carrierwave"
gem "aws-s3"
gem "mini_magick"
gem 'will_paginate'
gem "spreadsheet"
gem "oauth-plugin", ">= 0.4.0.pre1"
gem 'flash_cookie_session'
gem 'haml-rails'
gem 'squeel'
gem 'rails_best_practices', :group => :development
gem 'simple_form'
gem 'taps', :group => :development
gem 'resque'
gem "audited-activerecord", "~> 3.0"
gem "lograge"
gem 'quiet_assets'
gem 'yajl-ruby', :require => "yajl"
gem 'switch_user'
I've got no idea why I'm getting this error. Any thoughts? Thanks
With Rails 3.1.12 and Ruby 2.2.0 I had to add
gem 'test-unit'
to my Gemfile.
Removing test in the .slugignore file works for me.
Apparently Heroku has changed the way it interprets the .slugignore file.
In my case, I had rpc directory in .slugignore and it wiped out rpc subdirectory of one of the gems my app is depending on, which resulted in LoadError. I'm unsure Heroku made this change intentionally. Regardless of whether .slugignore is working as they expect, removing affecting line(s) from .slugignore should fix the issue for now.
P.S. I've raised a support ticket to Heroku on this.
UPDATE: As per Heroku support, there were some changes to .slugignore parsing to make it more consistent with .gitignore, and it is working as intended. The right way to only delete the top level directory is putting /rpc instead.
Removing test dir from .slugignore fixed the issue
Remove test dir from .slugignore
We also ran into this issue today. I suspect something must have changed in Heroku's Ruby build pack.
For us it was a problem with prototype-rails trying to load ActionView::TestCase which in turn requires test/unit/testcase. The patch is pretty simple and is available as a fork.
If you're using Bundler, you might want something like:
gem 'prototype-rails', :git => 'git://github.com/ennova/prototype-rails.git'
I tried disabling multithreading (comment out config.threadsafe!) and that seems to work for now until heroku gets their act together.

Trouble with Guard init command

I'm trying to setup Guard using this tutorial, however when I run bundle exec guard init or bundle exec guard init rspec
I'm on OSX, running RVM 1.14.1 and Rails 3.2.5.
I get the following errors:
[myapplication]$ bundle exec guard init rspec
/Users/ash/.rvm/gems/ruby-1.9.2-p290#myapplication/gems/guard-1.1.0/lib/guard/cli.rb:145:in `init': undefined method `create_guardfile' for Guard:Module (NoMethodError)
from /Users/ash/.rvm/gems/ruby-1.9.2-p290#myapplication/gems/thor-0.15.2/lib/thor/task.rb:27:in `run'
from /Users/ash/.rvm/gems/ruby-1.9.2-p290#myapplication/gems/thor-0.15.2/lib/thor/invocation.rb:120:in `invoke_task'
from /Users/ash/.rvm/gems/ruby-1.9.2-p290#myapplication/gems/thor-0.15.2/lib/thor.rb:275:in `dispatch'
from /Users/ash/.rvm/gems/ruby-1.9.2-p290#myapplication/gems/thor-0.15.2/lib/thor/base.rb:408:in `start'
from /Users/ash/.rvm/gems/ruby-1.9.2-p290#myapplication/gems/guard-1.1.0/bin/guard:6:in `<top (required)>'
from /Users/ash/.rvm/gems/ruby-1.9.2-p290#myapplication/bin/guard:19:in `load'
from /Users/ash/.rvm/gems/ruby-1.9.2-p290#myapplication/bin/guard:19:in `<main>'
RSpec runs fine:
[myapplication]$ bundle exec rspec
F
Failures:
1) StaticPages GET /static_pages works! (now write some real specs)
Failure/Error: get static_pages_index_path
NameError:
undefined local variable or method `static_pages_index_path' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007fd6d176a020>
# ./spec/requests/static_pages_spec.rb:7:in `block (3 levels) in <top (required)>'
Finished in 0.00887 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/requests/static_pages_spec.rb:5 # StaticPages GET /static_pages works! (now write some real specs)
Also my gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.5'
group :development, :test do
gem 'rspec-rails'
gem 'guard-rspec'
gem 'growl'
gem 'rb-fsevent'
gem 'spork-rails'
gem 'guard-spork'
end
gem 'sqlite3'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
I just had the same problem in Ubuntu Server 11.10. In my case there was some problem with the versions of the gems. I changed the guard gem version in the Gemfile from 1.1.0 to 0.10.0 and it worked. Here is my Gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'pg', '0.12.2'
group :development, :test do
#gem 'sqlite3', '1.3.5'
gem 'pg', '0.12.2'
gem 'guard','0.10.0'
gem 'rspec-rails', '2.9.0'
gem 'guard-rspec', '0.5.5'
gem 'guard-bundler'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.0'
group :test do
gem 'capybara', '1.1.2'
gem 'rb-inotify', '0.8.8'
gem 'libnotify', '0.5.9'
end
group :production do
gem 'pg', '0.12.2'
end
I've reported this issue and it has been fixed:
https://github.com/guard/guard/issues/283#issuecomment-6078721

Rails 3.1.1 Guard-rspec cannot run due to Growl errors: OSERROR: -10000 MESSAGE: Apple event handler failed

I have been running Guard for RSPEC and using the growl_notify gem for a while now (2-3 months), but now I cannot get guard to run in any of my Rails 3.1.1 projects. I've done some research on the error itself, but couldn't come up with anything conclusive (except someone else has the same issue).
Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.1.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'spreadsheet' # Allows for reading/writing Excel files. We also need a CSV importer, but that can come later
gem 'gmaps4rails' # Allows for Google Maps Pushpins/Markers/Places
gem 'scoped_search' # For Searching
gem "paperclip", :git => "git://github.com/thoughtbot/paperclip.git" # For File Uploads
group :test, :development do
gem 'sqlite3'
gem 'turn', '<0.8.3'
gem 'rspec-rails'
gem 'capybara'
gem 'guard-rspec'
gem 'growl_notify'
gem 'launchy'
gem 'capistrano' #You don't want Capistrano on the production side (I think)
end
group :production do
gem 'pg' #use postgres for database installation as the database
end
Error:
Thomas#Thomas-Cannons-MacBook-Pro:~/development/rails/tasks$ guard
/Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/rb-appscript-0.6.1/lib/appscript.rb:542:in `_send_command': CommandError (Appscript::CommandError)
OSERROR: -10000
MESSAGE: Apple event handler failed.
COMMAND: app("/Library/PreferencePanes/Growl.prefPane/Contents/Resources/GrowlHelperApp.app").register({:all_notifications=>["success", "pending", "failed", "notify"], :as_application=>"Guard", :default_notifications=>"notify"})
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/rb-appscript-0.6.1/lib/appscript.rb:642:in `method_missing'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/growl_notify-0.0.3/lib/growl_notify.rb:29:in `register'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/growl_notify-0.0.3/lib/growl_notify.rb:19:in `config'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.4/lib/guard/notifiers/growl_notify.rb:42:in `available?'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard- 0.9.4/lib/guard/notifier.rb:117:in `add_notification'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.4/lib/guard/notifier.rb:154:in `block in auto_detect_notification'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.4/lib/guard/notifier.rb:154:in `each'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.4/lib/guard/notifier.rb:154:in `any?'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.4/lib/guard/notifier.rb:154:in `auto_detect_notification'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard- 0.9.4/lib/guard/notifier.rb:80:in `turn_on'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.4/lib/guard.rb:184:in `start'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.4/lib/guard/cli.rb:74:in `start'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/thor- 0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/thor- 0.14.6/lib/thor.rb:263:in `dispatch'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.4/bin/guard:6:in `<top (required)>'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/bin/guard:19:in `load'
from /Users/Thomas/.rvm/gems/ruby-1.9.2-p290/bin/guard:19:in `<main>'
Here's what worked for me. Two things:
First, Guard 0.10.x. requires Growl >= 1.3. Install Growl 1.3 from the App Store (thew reviews are really bad, but I had no trouble).
Second, the new Guard versions recommend ruby_gntp. Simply replace gem 'growl_notify' with gem 'ruby_gntp'.
This appears to be a version mismatch between Growl and growl_notify. growl_notify 0.0.3 changed the Growl application name, which near as I can tell changed with Growl 1.3 (Lion only)
I believe it works out to:
use growl_notify 0.0.2 for Growl < 1.3
use growl_notify 0.0.3 for Growl >= 1.3
use growl gem (what I did)

Can't activate rack when running cucumber

I can no longer run cucumber in my rails 3 app. I'm not sure exactly when it broke but I did do some rspec work that required me to use the webrat gem and it was working before that.
My error is:
$ cucumber
Using the default profile...
can't activate rack (~> 1.2.1, runtime) for ["actionpack-3.0.7", "railties-3.0.7"], already activated rack-1.3.0 for ["rack-test-0.5.7", "cucumber-rails-0.4.1"] (Gem::LoadError)
Here is my Gemfile
source 'http://rubygems.org'
gem 'rails', '3.0.7'
gem 'sqlite3'
gem 'devise'
gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
gem 'cancan'
group :development, :test do
gem 'rspec-rails', '2.5.0'
gem 'rspec', '2.5.0'
gem 'webrat', ">= 0.7.2"
gem 'cucumber-rails'
gem 'capybara'
gem 'database_cleaner'
gem 'launchy'
gem 'factory_girl_rails'
gem 'spork'
end
Please let me know if I need to supply more info and I'll edit this.
I've tried specifying rack in my Gemfile but this doesn't seem to help and doesn't seem right. Also: If I modify my Gemfile I am running "bundle install" and then trying cucumber again. Is this the right workflow to solve this problem?
Can anyone please help?
Cheers,
Rim
Someone in my IRC channel pointed me in the right direction.
Use the context of bundler (which I don't quite understand yet)
bundle exec cucumber
This works just fine :)

Rails 3 Cucumber Load Error

I am trying to get cucumber to work with Rails 3.
But whenever I try to run the cucumber features I get an load error.
cucumber-0.7.3/lib/cucumber/ast/feature_element.rb:2:in `require': no such file to load -- gherkin/parser/tag_expression (LoadError)
I have added the following gems to the Gemfile
gem "rspec", '>= 2.0.0.beta.19'
gem 'capybara'
gem 'database_cleaner'
gem 'cucumber-rails', '~> 0.1.1.rc6'
gem 'cucumber', '~> 0.7.0.beta.8'
gem 'rspec-rails', '~> 2.0.0.beta.19'
gem 'spork'
gem 'launchy'
I'm running on ruby-1.9.2-p0
Any suggestions?
I was getting the same error and was able to move past it by forcing gherkin to be loaded in Gemfile instead of as a cucumber dependency.
So, assigning specific version to Gherkin and >= to cucumbers:
...
gem 'gherkin', '2.1.5'
gem 'cucumber-rails', '>=0.3.2'
gem 'cucumber', '>=0.8.5'
...