Rails Tutorial Sample App 6.26 - railstutorial.org

I am following along with the sample_app everything runs create and all specs pass until I get to 6.26. As soon as I add the has_secure_password to the User class I receive a Ruby interpreter error that is 1899 lines long. The buffer in vim only shows up to line 600 so I can't even get to the root of the problem. I have verified that I have all of the gems with the correct version numbers. Not sure where to go from here. I am not sure where to start debugging from here. I have made sure to rake db:migrate and rake db:test:prepare. Any help in where to start debugging or direction to take would be great.
Thanks

You're probably missing the bcrypt-ruby gem.
You need to add bcrypt-ruby (~> 3.0.0) to Gemfile to use
has_secure_password:
gem 'bcrypt-ruby', '~> 3.0.0'

This error had nothing to do with Rails Tutorial or RSpec. It ended up being an issue with running guard within a tmux session. Everything works fine if I open a second tab and run guard in a standard terminal.

Related

Ruby 1.9.1 Installation on Debian

Currently having a bit of a nightmare trying to run code on another machine. I've been developing a Sinatra app as part of an internship I'm doing. I'm developing on an Ubuntu 12.04 machine, with ruby1.9.3 (through RVM). My supervisor wants to run it on his Debian Squeeze machine, the development server. I listed all the necessary gems in the Gemfile, and pushed up the initial commit. However, we just can't seem to get it running on the Debian box.
Ruby1.8 was initially installed, before my supervisor was aware we'd need Ruby1.9 and up. The Ruby1.9.1-full debian package was installed, but trying to run the Sinatra app with the ruby1.9.1 application.rb does nothing. I added in some print statements to debug it, and the ruby interpreter is reaching the end of the file - the problem is that it is not starting up WEBrick. This exact same code has no problem running on my machine, why is it being so problematic on Debian?
NOTE: Don't suggest switching to RVM. My supervisor is adamant we only use official packages, so it's beyond my control.
I have my Sinatra apps configured a bit differently. That is, I don't run them with ruby application.rb, rather I have a config.ru file with instructions to the Rack middleware. When I want to run my app i just run rackup and the server will start.
The minimal example layout as shown in the Sinatra Readme is as follows.
A basic Sinatra application.rb file:
require 'sinatra'
get '/' do
'Hello world!'
end
and the config.ru:
require './application'
run Sinatra::Application
I don't really know if or how this would make a difference in your situation, but it was the first thing that sprung to mind.
P.S.
Now that I think of it, another thing you could try is to use another server than WEBrick. I think if you add
gem 'thin'
to your Gemfile it should automatically use Thin instead. Remember to re-run bundle install first.

changing to jruby, get RuntimeError: Server handler (thin) not found

My app works fine in MRI 1.9.2-p290 and 1.9.3-p125, but when I change to jruby-1.7.0-preview1 I get the error discribed. Here's the full error:
RuntimeError: Server handler (thin) not found.
detect_rack_handler at /home/qry_dev/.rvm/gems/jruby-1.7.0.preview1/gems/sinatra-1.3.2/lib/sinatra/base.rb:1402
run! at /home/qry_dev/.rvm/gems/jruby-1.7.0.preview1/gems/sinatra-1.3.2/lib/sinatra/base.rb:1293
(root) at /home/qry_dev/Ruby/query_engine/query_webserver.rb:320
load at org/jruby/RubyKernel.java:1017
(root) at -e:1
(I tried jruby-1.6.6 already, same error.)
The sinatra and thin gems (among others) are already installed. In fact, other than jruby instead of mri, everything's the same.
Any ideas? I've searched the web and seen this error, but it's usually for 3rd party tools, and nothing seems to apply.
EDIT: also tried installing thin (which I never had to do before) to linux itself via
sudo apt-get install thin
but still getting same error.
sinatra 1.3.2 (by default) checks only for mostly MRI compatible servers, see:
https://github.com/sinatra/sinatra/blob/e111243e813ede1f0f4c6918d9a8cc029e776fc3/lib/sinatra/base.rb#L1514
thin, mongrel do not work on JRuby due native C code (although there's effort to make them use some "native" Java code on JRuby)
you have two options either adjust the set server while on JRuby e.g. something like:
set :server, %w[trinidad webrick] if defined?(JRUBY_VERSION)
or rackup your application with the given handler rackup -s trinidad
do not forget to gem install trinidad first (under JRuby)
You can install thin server which sinatra will pickup automatically.
To install thin you can execute the following command
gem install thin

rvm installation fails on powerpc ibook g4

I am trying to install ruby version manager on a g4 ibook running 10.4 but I receive two error messages right off the bat when I try to run the first command:
$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
bash: line 6: set: errtrace: invalid option name
bash: line 13: conditional binary operator expected
I am new to ruby, rails, and fairly inexperienced with the command line too. I've done a bit of searching and have seen other people having problems installing a specific version of ruby on a powerpc using rvm, but no other examples of someone having a problem installing rvm first of all.
Does this seem like a powerpc issue? Or is there something simple with the command line that I am missing here?
I have also searched on these specific error messages but haven't found any solutions yet. Oh and I should also add that I have xcode installed and I also installed macports because I thought that might help...but it hasn't.
The most probable cause of the error you're getting is your bash version is far too old to be used with any relatively new RVM version. Also, the likelihood of you being able to easily compile rubies on a G4 now is very low. You'll likely end up needing to compile many tools and libraries from source which you'll have to do from the command-line. Finding the right combination of library versions that both support your arch and are still available for download might not be as easy as it sounds. Much of the ruby compilation on OS X depends on libraries that come with Xcode. So, you might hit a wall there too with rubies now requiring newer libraries that can be provided with a version of Xcode that can be installed on your system.
You can try upgrading your bash version and/or use a much older version of RVM, although, I don't remember RVM ever working on 10.4. Or, you can try to compile everything from source, including Ruby. You'll might be able to get Ruby 1.8.6, maybe 1.8.7 working but anything higher is very unlikely.
Good luck =/

Installing cocos2d 2.0 XCode templates

I'm trying to instal the cocos2d 2.0 XCode 4 templates but I keep getting errors when running the install script. I've tried to manually copy the templates but when I try to compile my project, it gives me a bunch of errors. Can anyone help?
Here are the errors that the install script throws at me:
http://pastebin.com/ZdmAxwef
Any help is greatly appreciated!
Thanks!
You probably install the cocos2d 1.x templates using root. Since installing as root isn't supported anymore, you first have to chown them back to your user.
There are three things you can try:
First, make sure you are running install-templates.sh as sudo
cd *location of cocos2d-2.0 folder*
sudo ./install-templates.sh -u -f
where -f forces the installation
Second, you may need to change the install-templates.sh script to install to a different location (try both your user and directly to the Machintosh HD)
Third, (which is what i often have done in the past) is copy the folders over to the correct directory (or at least make the directories the mkdir are failing on and try again)
I followed these exact instructions
cd /src/cocos2d-iphone-2.0/
./install-templates.sh -f
which i found here http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:migrate_to_v2.0
side note- on my mac hard drive "Macintosh HD" i created a folder src and copied the cocos2d-iphone-2.0 folder in it. and im running mountain lion and Xcode 4.4
this worked perfectly for me.
hope this helps
This is many years ago
The Solution is simple now, you know longer need to do any of this just.
install the latest version of Cocos2D from
cocos2d-swift.org
it will install everything automatically including the templates. just start a new Xcode project and it just be there in the template options

REE rake gems:install is not working correct

I've installed REE on CentOS 5 for a very special task (using rails 2.3.10 and ruby 1.8) and I really need it to be isolated
In this case I won't use bundler or smth so.
Everything works ok if I'll setup every gem manually via
/opt/ree/bin/gem install agem
But when I run
/opt/ree/bin/rake gems:install
in prepared for this command project - all (or most, I haven't check every dependency) gems are installed via /usr/bin/gem into common gem path, where I do not need any of them
This is an issue and I do not want to install all gems manually. Have smb ever hit into this issue and probably knows solution?
Solution that really helped me was to temporarily replace /usr/bin/gem with a symbolic link to /opt/ree/bin/gem
With this replacement /opt/ree/bin/rake gems:intall worked as expected - all required gems were installed to REE path - returning /usr/bin/gem to original gem executable made system stable again
This is not very clean solution but it works, so it can be used like hammer in critical situation.
There's either a GEM_HOME variable somewhere in the environment, or the runtime ruby called is not ree. Therefore, I'd suggest at least 3 things to try:
Start with an almost empty environment (run env -i sh for example) and run again the rake command, see if this is still installs gems in the common gem path. Be careful, because env -i is an empty environment, you might see complaints from rubygems (because no HOME or nothing else is set)...
Check that the shebang line (first line of the rake program) really indicates your REE binary and not something else
Finally, do run rake using the REE binary with /opt/ree/bin/ruby /opt/ree/bin/rake gems:install
This should give you an indication of what's going wrong. All in all, I think that the environment issue is probably the most probable culprit of this thing