Browse Folders as Root – Ubuntu

Just a quick post on how to browse folders as root in Ubuntu. Simply enter the following:

chris@chris-VirtualBox:/etc$ sudo nautilus

Once you’re in there you can view hidden files by pressing Ctrl+H.

If, like me, you’re coming from a Windows background – this may make things a little easier. Leave a comment below if you have any more useful tips!

sqlite3.h is missing – Ruby on Rails

Just an error I ran into while running bundle install on a new ubuntu virtual:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb 
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite-devel' and check your shared library search path (the
location where your sqlite3 shared library is located).
*** 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.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/usr/bin/ruby1.8
	--with-sqlite3-dir
	--without-sqlite3-dir
	--with-sqlite3-include
	--without-sqlite3-include=${sqlite3-dir}/include
	--with-sqlite3-lib
	--without-sqlite3-lib=${sqlite3-dir}/lib
	--enable-local
	--disable-local

To fix it, simply run the following:

sudo apt-get install libsqlite3-dev

Could not find a JavaScript Runtime – Ruby on Rails

Ran into the following issue today starting a new app on a virtual Ubuntu box:

Could not find a JavaScript runtime

Thankfully there’s a quick fix, simply install nodejs:


chris@chris-VirtualBox:~/Desktop$ sudo apt-get install nodejs


Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  postgresql-client-8.4 postgresql-8.4
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  libc-ares2 libev4 libv8-3.1.8.22
The following NEW packages will be installed:
  libc-ares2 libev4 libv8-3.1.8.22 nodejs
0 upgraded, 4 newly installed, 0 to remove and 77 not upgraded.
Need to get 1,938 kB of archives.
After this operation, 6,066 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://au.archive.ubuntu.com/ubuntu/ oneiric/universe libv8-3.1.8.22 i386 3.1.8.22-1ubuntu2 [1,386 kB]
Get:2 http://au.archive.ubuntu.com/ubuntu/ oneiric/main libc-ares2 i386 1.7.4-1 [37.3 kB]        
Get:3 http://au.archive.ubuntu.com/ubuntu/ oneiric/universe libev4 i386 1:4.04-1 [29.5 kB]       
Get:4 http://au.archive.ubuntu.com/ubuntu/ oneiric/universe nodejs i386 0.4.9-1ubuntu3 [486 kB]  
Fetched 1,938 kB in 18s (106 kB/s)                                                               
Selecting previously deselected package libv8-3.1.8.22.
(Reading database ... 158699 files and directories currently installed.)
Unpacking libv8-3.1.8.22 (from .../libv8-3.1.8.22_3.1.8.22-1ubuntu2_i386.deb) ...
Selecting previously deselected package libc-ares2.
Unpacking libc-ares2 (from .../libc-ares2_1.7.4-1_i386.deb) ...
Selecting previously deselected package libev4.
Unpacking libev4 (from .../libev4_1%3a4.04-1_i386.deb) ...
Selecting previously deselected package nodejs.
Unpacking nodejs (from .../nodejs_0.4.9-1ubuntu3_i386.deb) ...
Processing triggers for doc-base ...
Processing 1 added doc-base file...
Registering documents with scrollkeeper...
Processing triggers for man-db ...
Setting up libv8-3.1.8.22 (3.1.8.22-1ubuntu2) ...
Setting up libc-ares2 (1.7.4-1) ...
Setting up libev4 (1:4.04-1) ...
Setting up nodejs (0.4.9-1ubuntu3) ...
update-alternatives: using /usr/bin/node to provide /usr/bin/js (js) in auto mode.
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
chris@chris-VirtualBox:~/Desktop$

Let me know if you have any issues.

undefined method `render_with_scope’ (Devise) – Ruby on Rails

I ran into the following error while trying to implement ReCaptcha with devise:

undefined method `render_with_scope' for #

The offending code:

class Users::RegistrationsController < Devise::RegistrationsController
  def create

    #Verify captcha
    if verify_recaptcha
      super
    else
      build_resource
      clean_up_passwords(resource)
      flash.now[:alert] = "There was an error with the recaptcha code below. Please re-enter the code."
      render_with_scope :new
    end
  end
end

This error was caused by the fact that I’d followed an out of date tutorial. Devise no longer uses render_with_scope. Thankfully the solution was pretty straight forward, simply switch render_with_scope with render:

class Users::RegistrationsController < Devise::RegistrationsController
  def create

    #Verify captcha
    if verify_recaptcha
      super
    else
      build_resource
      clean_up_passwords(resource)
      flash.now[:alert] = "There was an error with the recaptcha code below. Please re-enter the code."
      render :new
    end
  end
end

There’s a brief explanation available at the following link: http://groups.google.com/group/plataformatec-devise/browse_thread/thread/596381554ba1fb04