Launching RoR server for an existing app gives error - ruby-on-rails

I just made my first setup of RoR, and creating a new application works fine. But when I want to run the rails server I get the following error:
C:/Ruby192/lib/ruby/gems/1.9.1/gems/delayed_job-2.1.3/lib/delayed/yaml_ext.rb:30:in 'remove_method': method 'to_yaml' not defined in Class (NameError)
I ran the "bundle install" in the app directory and installed all the necessary files (with some problems however, but I excluded the gems with problems in the gemfile) and the last bundle install said that I have successfully installed all the needed packs.
I'm lost and I can't find a similar error on the internet. Can you help me?
EDIT: I forgot to mention that I'm not having a problem with a new application. It's running an existing one (that I didn't build, but works fine for others) that the error is related to. Here's the gemfile for that app:
source 'http://rubygems.org'
gem 'rails', '3.0.3'
gem 'mysql'
gem "haml", ">= 3.0.0"
gem "haml-rails"
gem 'simple_form'
gem 'delayed_job'
#gem 'auto_crawlers'
gem 'will_paginate', '~> 3.0.beta'
group :test do
gem 'factory_girl_rails'
gem 'mocha'
end
group :development do
#gem "nifty-generators", "0.4.3", :git => "git://github.com/JonasNielsen/nifty-generators.git"
gem 'fastercsv'
end
gem "mocha", :group => :test
Do you think the error is because I left out the two gems with "#" ? Those were causing problems at first, and I don't think I need them to test some minor changes in the app (some views that I have to modify)

The issue is being described, and supposedly fixed here: https://github.com/collectiveidea/delayed_job/issuesearch?state=open&q=yaml#issue/194

Try this from the command line: irb -rubygems -r delayed_job and then from your bundled directory bundle-exec irb -rubygems -r delayed_job which will show if there is a difference between your system gems and your bundled setup - you might see an error in one or both attempts to run IRB.
If there is an error using bundle-exec but not with your system gems then it's a bundler issue. If not, are you sure the app is designed to function under Ruby 1.9? It looks like to_yaml isn't available at the point DJ is required, which implies it probably needs a require "yaml" somewhere.

Related

Unicorn not happy with my rack version?

I have been repeating this tutorial for weeks now:
https://www.digitalocean.com/community/articles/how-to-1-click-install-ruby-on-rails-on-ubuntu-12-10-with-digitalocean
Here are the specifics of my project:
I am using Mongoid with database.yml production set to my tested and working Droplet (DigitalOcean VPS) running MongoDB.
My gem file is here, I am new to Rails and am not quite sure if it's set up right, so I just moved them all to assets hoping Unicorn might serve these gems for me?
source 'https://rubygems.org'
gem 'rails', '3.2.14'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem "therubyracer"
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "twitter-bootstrap-rails"
gem 'redcarpet', '1.17.2'
gem 'uglifier', '>= 1.0.3'
gem "will_paginate_mongoid"
gem 'will_paginate', '~> 3.0.5'
gem 'will_paginate-bootstrap'
gem 'devise'
gem 'jquery-rails'
gem "mongoid", "~> 3.0.0"
end
Here's what I did:
I used DigitalOcean's 1 click installer. Then I used FileZilla to SFTP into the credentials they provided me with. I deleted all the files in /home/rails and put my new files in from my project. Then I executed bundle install, and restarted the unicorn service. In the tutorial I had seen I can track the log of unicorn, so I executed this: tail -f /home/unicorn/log/unicorn.log
Here is the output which concerns me:
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in `block in setup': You have already activated rack 1.5.2, but your Gemfile requires rack 1.4.5. Using bundle exec may solve this. (Gem::LoadError)
I saw some other solutions to this, all failed. Here are the solutions I tried:
Deleting my Gemfile.lock, and re bundle installing it. Going into the file and removing where it said rack. Running bundle install --binstubs. Restarting the unicorn service with bundle exec before it. The error remains the same.
I've had many different errors before, but I feel this is the closest I have gotten. If someone could explain this to me (I'm new to Rails and would like a thorough explanation) and possibly help me fix the error that would be fantastic and end this frustration.
Just a wild guess
gem "rack", "~> 1.4.5"
May work for you, then of course bundle install afterwards.
This solves the problem:
gem uninstall rack -v 1.5.2
Possibly reload your Ubuntu installation from the DigitalOcean control panel, then try and install Ruby on Rails with Apache and Passenger?
Install RoR
Install Passenger (skip to passenger installation)
You will have errors when first creating your site with rails new as it will try and use SQL when it won't be installed, if you wish to use MongoDB

Ruby on Rails: Getting NameError whenever delayed_job gem is used

Totally stumped on this one and hoping some RoR expert can help.
Hitting this strange error where if I install the delayed_job gem, my site (development env) just stops working. All controllers and methods will show a NameError exception:
NameError in ProductsController#show
cannot remove Object::ClassMethods
I know it's the delayed_job gem because if I uninstall it or comment it out, restart the server, the errors go away.
My gemfile looks like the following:
source 'http://rubygems.org'
gem 'rails', '3.0.10'
# Bundle edge Rails instead:
gem 'delayed_job', "2.1.4"
gem 'sqlite3'
gem 'faker', '0.3.1'
gem 'webrat', '0.7.1'
gem 'will_paginate', '3.0.pre2'
gem "amazon_product", "3.0.0.pre.2" #http://code.papercavalier.com/amazon_product/
gem "curb"
gem "authlogic"
gem "omniauth", ">=0.2.6"
gem "faraday"#, ">=0.7.4"
gem "fb_graph"
gem "twitter"#, "~> 1.7.1"
I am using Ruby 1.8.7 and Rails 3.0.10.
If you have any idea what might be the problem, please help :)
I figured out what the culprit was. In my controllers, I was including "#include ActionView::Helpers::TextHelper" at the top so I can use the truncate function. Including that apparently cause some naming conflicts withint delayed_job. Removing the include solved my problem.

Getting Autotest to Work with Growl on OS X

I'm using Ruby 1.9.2 and Rails 3.0.7 on Mac OS X 10.6.7.
I have had the most terrible time getting growl to display autotest notifications. I have autotest installed and working perfectly.
Every time I make a change to a file, the tests are run without a problem. Growl simply refuses to work. In my Growl preferences panel I can see that autotest is added to the list of applications and enabled and Growl is on and running. Here's what my gemfile looks like:
source 'http://rubygems.org'
gem 'rails'
gem 'sqlite3-ruby', :require => 'sqlite3'
group :development do
gem 'rspec-rails'
gem 'annotate-models'
end
group :test do
gem 'rspec'
gem 'webrat'
gem "ZenTest"
gem "autotest-rails-pure"
gem "autotest-growl"
gem "autotest-fsevent"
end
And here's my .autotest file:
require 'autotest/growl'
require 'autotest/fsevent'
I've tried everything I can think of to get this to work. I tried:
following the first two pages of guides on Google for autotest and OS X.
deleting my gemset in RVM and reinstalling.
running bundle install dozens of times.
installing the test_notifier gem.
None of these steps seemed to work. I'd appreciate any help or suggestions. It's been a frustrating two days trying to get this to work.
You might want to consider using Guard-RSpec to run your specs. It's easy to install, and it works with Growl. Be sure to look at the base Guard gem. I've switched over from Autotest over a month ago and have been happy. Here's the Railscasts about Guard.
Have you tried putting gem 'autotest-growl' in your development group? I've always put it there and have had no problems; I've just assumed it's the same reason that you have gem 'rspec-rails' in your development group.

Help with Ruby on Rails Gem file and bundle install

I am trying to learn rails from http://ruby.railstutorial.org/
Exercise 3 explains to install rspec, rspec-rails, and webrat using this gemfile
source 'http://rubygems.org'
gem 'rails', '3.0.6'
gem 'sqlite3', '1.3.3', :require => 'sqlite3'
group :development do
gem "rspec-rails", ">= 2.0.1"
end
group :test do
gem "rspec-rails", ">= 2.0.1"
gem 'rpsec'
gem 'webrat'
end
i have tried to install rspec-rails and webrat and they seem to have installed correctly.
C:\RubyProject\sample_app>gem install rspec-rails -v=2.0.1
**************************************************
Thank you for installing rspec-rails-2.0.1!
This version of rspec-rails only works with versions of rails >= 3.0.0
To configure your app to use rspec-rails, add a declaration to your Gemfile.
If you are using Bundler's grouping feature in your Gemfile, be sure to include
rspec-rails in the :development group as well as the :test group so that you
can access its generators and rake tasks.
group :development, :test do
gem "rspec-rails", ">= 2.0.1"
end
Be sure to run the following command in each of your Rails apps if you're
upgrading:
script/rails generate rspec:install
Even if you've run it before, this ensures that you have the latest updates
to spec/spec_helper.rb and any other support files.
Beta versions of rspec-rails-2 installed files that are no longer being used,
so please remove these files if you have them:
lib/tasks/rspec.rake
config/initializers/rspec_generator.rb
Lastly, be sure to look at Upgrade.markdown to see what might have changed
since the last release.
**************************************************
Successfully installed rspec-rails-2.0.1
1 gem installed
Installing ri documentation for rspec-rails-2.0.1...
Installing RDoc documentation for rspec-rails-2.0.1...
But when i run bundle install
I get the following error message
Could not find gem 'rpec-rails (= 2.0.1)' in any of the gem sources listed in your Gemfile.
So me being a total newbie to RoR has no idea why this is occurring. I have tried following this link
http://railsforum.com/viewtopic.php?id=41464
which seems to be a dead end. I'm hoping that someone here can point me in the right direction. Any help would be appreciated.
If your output is correct:
Could not find gem 'rpec-rails (= 2.0.1)' in any of the gem sources listed in your Gemfile.
Then it looks like you've got a typo in your gem file. You've installed the gem, but it won't bundle with the app since you didn't spell rspec-rails correctly. Check your declarations in the gem file.
It is an annoying word to spell.
I noticed your :test group contains a typo: rpsec instead of rspec.

How do you tell rails to generate integration tests using rspec and webrat?

I'm working through the Ruby on Rails Tutorial and I'm getting stuck on the integration tests. When I try to generate the integration tests for layout_links, I get the following comments in the generated test:
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
And I don't see the "response.should be_success" syntax that I expect. I think I've managed to hose my installation somehow but I don't know how to see which gems I have on the system and how to uninstall/reinstall them.
[edit]I do have webrat configured in the "test" section of my Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem 'sqlite3-ruby', '1.3.2', :require => 'sqlite3'
group :development do
gem 'rspec-rails', '2.5.0'
end
group :test do
gem 'rspec', '2.5.0'
gem 'webrat', '0.7.1'
end
Any help would be greatly appreciated.
I believe that message means that webrat was not detected when the scaffold was generated. Look in your projects Gemfile for:
gem 'webrat'
Add it if it's missing, then run bundle install, then run the generator again.
I've gotten this to work and the problem seems to be my ruby/rails installation. I'm running Ubuntu and I think I've mixed a few packages installed via apt with those installed via bundle and gotten my system confused. I've followed this tutorial on installing Ruby on Rails in Ubuntu using rvm and now I can generate and run my tests again. I'm still having a few issues with autotest which I believe are related to conflicting packages. rvm looks like it's a much better way to set up a rails environment than apt and it allows you to only install your rails environment for one user. This way, you can set up a test user to make sure you get everything configured correctly without changing your entire system.
Thanks for all of the help.

Resources