Skip to main content

Posts

Showing posts from July, 2012

Installing RVM on Linux Mint 13

Linux Mint has captured my imagination recently, and of course a fresh install means getting my dev environment up and running again. I'm using the cinnamon version and so far things are going well. Everything on my laptop is just working; suspend, all the various function keys. Support out of the box is good. I'm impressed. The experience is soooo much better than the last time I tried a more full featured distro and things got so bad with video drivers crashing and causing my fan to spin up constantly that I ended up going totally minimal with Arch and just a command line. I like arch, but I thought I would give Mint a go. So, now we need to get Ruby, RVM and Rails on the go so we can do some web development. Let's start with RVM. Next time I'll take a crack at installing Rails on Mint First things first - we need curl. My install didn't have it so.....fire up the terminal with Ctrl-Alt-T and type the following sudo apt-get install curl Next up, install RV

Jekyll and ruby 1.9.3 site not regenerating

If you are trying to compile a site with Jekyll and ruby 1.9.3 and you have some dodgy yaml front matter in one of your posts, your site just won't regenerate. Step 1 is to edit your _config.yaml and set auto: false. If you leave auto:true then it won't report the errors at all. With that, if you run your jekyll --server command again, you could get an error to the effect of "did not find expected key while parsing a block mapping at line" blah blah blah. The error isn't particularly useful. However, help is at hand - see this pull request which you can manually apply to your gem if you want and you'll start to get meaningful error messages again. I monkey patched mine by editing my lib/jekyll/post.rb file to include the pull request's code. I guess you could use RVM and use an older ruby version, but this did the job for me

Creating flash messages bootstrap style

I'm on a twitter bootstrap binge at the moment, it fills my soul with glee to start a new project with a base template that looks better than the usual dog's breakfast. Anyway, there are days when you just need a piece of code to blast in to your templates so that you can get on with your work. This is one of those and slapping the tremendous bootstrap success, warning and info messages into our normal flash message stylings is just what the doctor ordered. Here then, for your delectation, a small snippet of code to pop into your application layout in place of your usual flash message code that will style things up the bootstrap way. If you prefer, pull this out into a helper.....if you think that's the rails way. Personally, for small projects, I don't bother.

Add css class to your label form helpers

Say, for example, you are using Twitter Bootstrap to style up a quick rails app and you want to throw in a label tag with the class set to "control-label" just like the bootstrap guys do.....how do you do it? And more importantly, since you don't want to specify the text of the label, how do you accomplish that? Fear not intrepid young but soon to be rails guru, behold the truth:

Nginx and Rails into development mode

If you are running a rails app with nginx serving it up and you want to put the whole shebang into development mode, open up your nginx.conf file and in the server section, add the following line: rails_env development; Remember though, it takes a ton more resource to do this so remove the line when you're done. Part of the fun of doing this is if you are hacking away on a project and you want to skip the precompiling of assets and such.

Redirect www to naked domain in nginx

Redirecting a www based domain to a non-www based or naked domain is pretty easy - in the nginx conf file, you'll need something like this: server { listen 80; server_name www.example.com; rewrite ^(.*) http://example.com$1 permanent; } server { listen 80; server_name example.com; ...rest of your conf } You might not want to do this though. Using naked domains is not always the best idea .

Installing a gem with no documentation

Often you will want to install a gem on your local system or server, but you don't require the documentation, you want to leave it out. This not only speeds up the install, but saves some space on your machine. Here's the script to run from the command line if, for example you were installing the rack_csrf gem: The reason for both "no-ri" and "no-rdoc" is because there are actually two types of documentation being installed - the RDoc is essentially embedded documentation generator for the Ruby language. It will analyze source code and create the documentation. the Ruby ri files are to all intents and purposes Ruby's version of man pages which give you documentation from the command line.