Skip to main content

Posts

Showing posts from August, 2012

Rails 3.2 Could not find a JavaScript runtime execjs

Running a fresh copy of Linux Mint and Rails lets you generate a new project with no problems, but you might start to hit issues as soon as you start trying to generate some scaffolding. So for example, if you try rails g scaffold User name:string email:string You'll get something like this: /home/x/.rvm/gems/ruby-1.9.3-p194@rails3.2/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51 in 'autodetect': Could not find a JavaScript runtime. It will also tell you to visit https://github.com/sstephenson/execjs to see a list of available runtimes. Don't be shy now, head over there and take a look. Or, if you just want to hack it, add the following to your Gemfile: gem 'therubyracer' Run your bundle update and you should be good to go.

Triple boot Linux, Windows 7 and Windows 8 RTM

I wanted to have a triple boot computer - why? don't ask me why! Oh, ok, I'll tell you - I needed Windows 7 for some current work and didn't want to mess up the install. I wanted to install Windows 8 so I could play with the metro style app development that I've seen floating around and of course, I like my Linux system for my ruby web development . So - here's the rough steps without a specific walk through of each one, except for reinstalling grub, which is really the crucial step to getting everything to hum and purr along nicely. The caveat is that this worked for me, on my system, it might not work on yours - so take precautions, backup, verify backup, store a backup off-site - you know the drill, I shouldn't need to tell you.: 1) Install Windows 7 Easy enough, follow the prompts and pop Windows 7 on your machine. 2) Install Linux Choose your flavour - I've got Mint up and running, but go for Ubuntu if you prefer. Actually, go for pretty much whate...

Generate an absolute URL in padrino

Sometimes, you just need that absolute URL. Padrino gives you a great little helper to create your urls in th form of url_for. Unfortunately, Padrino's documentation seems to be written from the point of view of someone who is intimately familiar with Rails, which means the total noob trying to get into Padrino without any Rails experience can be left a little flummoxed. Anyway, it is important to realise that Padrino has Sinatra as its base and you can tap into all that goodness that Sinatra offers. Absolute urls are as simple as: value) %> Lovely.

Ruby LoadError: cannot load such file

So, you've set yourself up a lovely new app using, for example, Sinatra , and you're really chaffing at the bit to write some lovely code. But you keep getting bit by this: LoadError: cannot load such file -- sweetsweetcode You double check your config.ru but it is pretty standard stuff: require 'sweetsweetcode' run Sinatra::Application What can be wrong? Please tell me oh gods of Ruby. Is it Passenger? Is it Rack? Have I uncovered a great big bug in Ruby itself? Naaaa! Of course not you fool, it's just that you're on the very latest version of Ruby, probably 1.9.3 or something and the load path no longer includes the current path. So to fix it, just do this: require './sweetsweetcode' run Sinatra::Application And you should be singing again.

Adding an item to Linux Mint Cinnamon Menu

Last time I took you through installing Sublime Text 2 on Linux Mint . The trouble with doing the install the manual way as I showed and not using sudo apt-get is that you don't get the neat integration into the operating system so you wont find Sublime Text in your Menu and if you search it wont be there yet. Right click on the "Menu" in the bottom left and choose "Edit Menu". You should have something that looks like this: Excellent. On my install, Programming was not yet ticked, so I clicked the checkbox so that the Programming section would show up in my Applications menu. Then on the left hand side, you need to click Programming, or whichever other category you want to put Sublime Text into and then on the right, click the "New Item" and fill it in as follows: If you followed along when I installed Sublime Text, you aliased subl to launch Sublime Text. Clicking where the icon is will let you choose the icon location. I used the 48x48 icon...

Padrino, Datamapper, Rake, Uninitialized Constant

So, perhaps you've set up a fancy application using padrino , datamapper and sqlite and you are going great guns until padrino rake dm:migrate => Executing Rake dm:migrate ... rake aborted! uninitialized constant Text Or something similar - the datatype is probably not too important. The solution is to edit your migration and put the datatype into quotes....like this: column :description, "TEXT" There seems to be a bug with the use of datamapper and the migration. I'm not sure where the bug is, but this fixes it!

Installing Sublime Text 2 on Linux Mint

So, continuing on from installing RVM on Linux Mint and installing Ruby on Rails on Linux Mint , I want to give a brief rundown on installing Sublime Text 2 on Linux Mint, though in fact, this will work for pretty much any Linux version, so if you're running Ubuntu it will work as well. If you aren't using Sublime Text 2 , I suggest you download it and give it a go - it's an awesome editor, especially for Rails and Python development, bringing a Textmate elegance to Linux. It's cross platform too, so if you are jumping between OSX, Linux and Windows, it makes the perfect companion giving you a consistent interface across the various OSs. Don't trust me? Well take a look at what others think about it So, there are two routes here - you can install using the traditional apt-get on Mint. You'll have to add a repository. That's not really my preferred method though. It takes too long to get releases through to the repository so I like to do a manual insta...

Installing Rails on Linux Mint 13 with RVM and gemsets

Last time I did a quick RVM install guide for Linux Mint . This time I'm going to finish up by installing rails so we can rock some new development work. Nothing like a clean and humming system I tell you. Let's begin by making sure we have git - we are going to be using it anyway. Fire up your terminal (Ctrl-Alt-T) and type sudo apt-get install git Great - version control level unlocked. We should have rubygems installed already (if you followed along with the RVM install then this is all taken care of). Now, to make sure RVM functions well, see this https://rvm.io/integration/gnome-terminal/ . Or, if you prefer, just move the commands from .bash_login to .bash_profile. As I understand it, and I'm no Linux guru, .bash_login doesn't run if .bash_profile is present. I'm going to create a gemset to install rails 3, just for fun...and just in case I want to go back and work on some legacy apps. rvm gemset create rails3.2 And set it so it is the default gems...