Prologue with Ruby on Rails 3 - ruby-on-rails-3

I'm a total newbie to RoR and am trying to get the Prologue gem up and running. I've downloaded the prologue zip file from github.com/quickleft/prologue and am trying to follow the instructions in the associated readme file. I have encountered a number of issues....
Q1: What do I actually do with the extracted zip file? For instance, am I supposed to place the extracted files inside specific rails application directories or what ?
I've been able to install the gem by executing "gem install prologue". However, I cannot create a new application using the "prologue new my_app" command - the following message is displayed at the command prompt when I execute that command:
*C:/Ruby192/lib/ruby/gems/1.9.1/gems/prologue-0.3.10/lib/prologue/cli.rb:58:in ``
': No such file or directory - git config --global user.name (Errno::ENOENT)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/prologue-0.3.10/lib/prologue/cli.rb:58:in `git_user_name'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/prologue-0.3.10/lib/prologue/cli.rb:33:in new'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/task.rb:22 :inrun'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in invoke_task'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor.rb:263:in dispatch'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/base.rb:38
9:instart'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/prologue-0.3.10/bin/prologue:4: in <top (required)>'
from C:/Ruby192/bin/prologue:19:inload'
from C:/Ruby192/bin/prologue:19:in `'*
Q2: Does anyone have any advice on how to overcome this problem?
Q3: Also, when attempting to get prologue up and running is it possible to do this without integrating it into an existing rails application? If so, how?
(I have ruby 1.9.2 and rails 3.0.0 installed on a Windows Vista machine)
Advice/feedback on the above issues would be greatly welcome!

It seems that Prologue needs 'thor', another gem. You can install all dependencies with the command 'bundle install'.
You can integrate Prologue in a new Rails app, but you definitely need some (existing or new) Rails app to run it.

Related

rvm using /after_cd_bunlder vs --binstubs. How are these different?

How are the outcome of these two methods different? Why use one over the other? I believe they both end up enabling you to issue 'rake' or 'rspec' without the preceeding 'bundle exec". My guess - with method 1 you only have to do this once, and then on ALL new rails project for the rvm ruby version will automatically have the desired feature ( as explained above)?
Method 1:
rvm get head && rvm reload
chmod +x $rvm_path/hooks/after_cd_bundler
bundle install --binstubs
OR
Method 2:
bundle install --binstubs
If found this documentation, but it did not help me understand which method to use. I looked on http://rvm.io and found intergration/bundler and /workflow/hooks.
The is code for after_cd_bundler (but I cannot post anymore links due to stackoverflow.com limitations on me)
This are not two different methods, this is one method and it is described in more detail here: http://robots.thoughtbot.com/post/15346721484/use-bundlers-binstubs
If you are using RVM then you do not need any of this, using --binstubs requires adding to PATH - which is big security risk if used from project directory, RVM comes with rubygems-bundler gem preinstalled which does the automatic loading of bundler (no need for bundle exec), you can find more details about the gem here: https://github.com/mpapis/rubygems-bundler#readme
I am author of rubygems-bundler and maintainer of RVM.

Rails 3 in test env won't allow records to save, even with latest sqlite3

I saw this post:
Rails/ActiveRecord/SQLite3: Can't save records in test environment
And after upgrading my sqlite version to the very latest (3.7.17), I am still getting the following error:
ActiveRecord::StatementInvalid: SQLite3::SQLException: near "SAVEPOINT": syntax error: SAVEPOINT active_record_1
Any time I try to create anything at all. If all I do is load my fixtures, everything is fine.
I have confirmed that rails is using the updated sqlite3 version by running "rails db".
In my development environment, I can create objects all day long with no errors (I can even have an object create another object after create).
What is special about my test environment that this is happening? How can I fix it?
Edit:
If I delete my test database, and redo rake:db:create and rake:db:migrate, I still get the same issues.
Doing "rails console test" lets me use the test environment just fine, and I can create objects all day long and see existing fixtures. It's only when I type "rake test:units" that I get the errors... (originally I had errors, but one error was legitimate (I don't know why I wasn't getting it in the development environment, and the adapter error was because apparently you aren't supposed to do "rails console RAILS_ENV="test", so it was looking for an adapter for an envrionment called "RAILS_ENV=test")
Edit: When I type "gem uninstall sqlite3" it uninstalls. When I then type "bundle install" it has a problem reinstalling...working on it now.
/home/jenny/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb --with-sqlite3-dir=/usr/local/bin/sqlite3 checking for sqlite3.h... *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check
the mkmf.log file for more details. You may need configuration
options.
If I type "gem install sqlite3" separately, it works just fine, and then "bundle install" it works. However, "rake test:units" has the same errors.
Edit:
When I type "which sqlite3" it prints out "/usr/local/bin/sqlite3"
I wasn't even aware sqlite3 headers were a thing, so I doubt I installed them. I'll try to figure out how to confirm this and see if it helps.
Edit:
I don't see anywhere to download sqlite3 headers on the main site...just source and the precompiled linux binary. There doesn't seem to be a special header in the source, but even if there was, wouldn't it be included in the precompiled binary?
EDIT: link to bundler sqlite3 install error that don't happen when i manually install the gem
http://pastie.org/8063577
EDIT: Not a devise problem. I thought it was, but it turned out I was just creating another object in fixtures, not in the test code.
So, I can create devise User or any other type of object in fixtures all day long, but if I attempt to create one in the unit test, I get the save point error. Same thing for trying to save a fixture in a unit test.
Your problem is most likely related to the fact that you updated your local sqlite but after that you haven't reinstalled your sqlite3 gem.
I'd recommend you follow these steps:
Remove the corresponding line gem 'sqlite3' from your Gemfile
Run bundle install
Run gem uninstall sqlite3
Return the line gem 'sqlite3' to your Gemfile
Run bundle install one more time
If you simply gem uninstall and then bundle install, it will install the same version and dependencies that were recorded in Gemfile.lock. But since you're now using a different and more updated local version, it's safer to allow Bundler to install a new version if needed.

Delayed_job(2.1.4) + Rails(3.0.10) undefined method `delay'

I upgrading a rails application to rails(3.0.10) and update the gem delayed_job. I updated my migration for the table delayed_job but unfortunatly the method ".delay" doesn't work.
NoMethodError: undefined method `delay' for #<User:0x10394d140>
I didn't find a solution for that. I did : "bundle install", I restarted the server, tried to instal as plugin...
Do you have any ideas?
Thanks.
UPDATE :
I fixed the problem but created a file config/initializer/delayed_job.rb with
require 'delayed_job'
Delayed::Worker.backend = :active_record
Sometimes gems just refuse to install properly. I think what you should do is (assuming you have git installed, otherwise go here https://github.com/tobi/delayed_job and download delayed_job as a zip file)
git clone https://github.com/tobi/delayed_job.git
take what he has in his lib folder and put it in yours. wherever you need to use his methods then do
require 'delayed_job'
in the top of those files
I checked this tutorial, it shows a way to setup in rails 3
http://www.dixis.com/?p=335
it suggests using this in your gemfile
gem "delayed_job", :git => 'git://github.com/collectiveidea/delayed_job.git'
(if it doesn't work with this either, then try the same thing that i did, but replace
git clone https://github.com/tobi/delayed_job.git
with
git clone https://github.com/collectiveidea/delayed_job.git
tell me if anything works

Global access to Rake DSL methods is deprecated

I am working through the Ruby on Rails 3 tutorial book and typed the following on the command line:
rake db:migrate
which produced the following warning.
WARNING: Global access to Rake DSL methods is deprecated. Please Include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method DemoApp::Application#task called at /Users/imac/.rvm/gems/ruby-1.9.2-p180#rails3tutorial/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks'
I am not sure what to do about it or how to work with it. I don't know any other command for Rake.
How can I fix this problem?
Adding include Rake::DSL to the Rakefile before the applications load_tasks were called also worked for me.
So in the above user's case before the DemoApp::Application.load_tasks in the Rakefile.
I found this in Stack Overflow question Ruby on Rails and Rake problems: uninitialized constant Rake::DSL. It refers to a #DHH tweet.
Put the following in your Gemfile
gem "rake", "0.8.7"
You may see something like
rake aborted!
You have already activated Rake 0.9.1 ...
I still had a copy of Rake 0.9.1 in my directory so I deleted it.
You can "delete" Rake 0.9.1 by running the following command:
gem uninstall rake -v=0.9.1
If you have multiple versions of the gem installed, you'll be prompted to pick a version.
After 0.9.1 was cleaned out, I ran
bundle update rake
and was finally able to create my database files. I was using rake db:create, but it should work for rake db:migrate as well.
I hope it helps.
I was having the same problem on Windows with the installer. Ruby 1.9.2 and Rails 3.0.9.
Here is what I did:
bundle update rake
bundle show rake
After doing that I was running rake 0.9.2.
Then I updated the Rakefile in application root folder as follows:
require File.expand_path('../config/application', __FILE__)
require 'rake'
# If you named your application something other than SampleApp, change that below
module ::SampleApp
class Application
include Rake::DSL
end
end
module ::RakeFileUtils
extend Rake::FileUtilsExt
end
SampleApp::Application.load_tasks
As noted in the comment, make sure the name of your app is correct in the two appropriate lines above.
If you are seeing this on later versions of Rails (like 3.+) you may also want to verify that your environment is clean by using RVM http://beginrescueend.com/ and creating a specific ruby & gemset for your projects.
Use an .rvmrc file on a per-project basis, this will guarantee you aren't getting older system gems into your projects. Which has bitten me before.
This prevents having to monkey around with generated Rakefiles & such.
bundle exec rake db:migrate will solve your ruby version issues

Heroku app crashes, logs say "No such file to load -- nokogiri (LoadError)"

I had a working app, added Nokogiri, to parse some xml, runs fine locally.
My Gemfile includes: gem 'nokogiri'
I ran bundle install and verified my Gemfile.lock includes DEPENDENCIES ... nokogiri
In my controller class I added (didnt thinkI had to but got an error locally if I didnt):
class MydealController < ApplicationController
require 'rubygems'
require 'open-uri'
require 'nokogiri'
when I use my browser to get the url in MydealController that uses nokogiri doc = Nokogiri::XML(getresult) Heroku crashes.
heroku logs shows this error No such file to load -- nokogiri (LoadError)
Looking at what happens when I git push heroku I do not see nokogiri on the list of many many gems that get installed. Heroku says the push was fine, but nokogiri is not listed and I get the aforementioned error...
It seems that when using Windows Gemfile.lock will contain version of nokogiri gem specific for windows, solution is to remove Gemfile.lock and push to heroku.
More info on this subject here
Your mission should you choose to accept it.
Ensure:
nokogiri is in Gemfile.lock
Gemfile.lock is committed to git
you push the commit that has nokogiri in Gemfile.lock to Heroku
Good luck! This message will self destruct in 10 seconds...
Just had the same problem -- you have to run bundle install to get it added to the Gemfile.lock which heroku looks at to find uninstalled dependencies.
This might help to understand the reason:
http://devcenter.heroku.com/articles/ps
Indeed removing Gemfile.lock might help. All other compiled gem will cause isseu. Best way is to ask Heroku's support.
Only found this article:
http://ganeshprasadsr.blogspot.com/2010/10/installing-nokogiri-for-rails-3-app-on.html
Try to remove require 'nokogiri' from controller.
It works for me.