Archive for January 2012
-
Rails 3.1: Treating your '.swf' files as assets
January 12, 2012
This post was originally published in the Rambling Labs Blog on January 12, 2012.
This week, I’ve been deploying one of my current Ruby on Rails projects to WebFaction. For what we found, it’s definitely one of the best options out there for shared hosting with Python and Ruby.
The application being deployed happened to contain some static flash content (not my idea of course :P), which so far we had put in the
public/
directory and had served with no problems so far, while testing locally and on Heroku. However, when we were testing it out on WebFaction, it kept returning 404 errors.So, googling for a while, I stumbled into the swf_fu gem. It’s main function is to treat the swf objects as just another asset in the application. So,…
-
jQuery Rambling Slider v0.3.1 is out!
January 7, 2012
This post was originally published in the Rambling Labs Blog on January 7, 2012.
Version 0.3.1 of the jQuery Rambling Slider has been released! You can download it from GitHub and test it out.
The latest documentation of the jQuery Rambling Slider can be found on the project’s wiki on GitHub.
There was an issue with the slider not working on IE 8, due to an undefined function. I have to thank the people that emailed me about it. Because of them I was able to spot the issue and fix it!
This release includes the following:
- Removed dev7 logo and added RamblingLabs logo.
- Added the box and slice generators.
- Removed some unnecessary
px
suffixes (top
,left
,right
,bottom
). - Fixed
indexOf
issue with IE 8. - Some additional refactoring.
If…
-
Rails 3.1 - Adding custom 404 and 500 error pages
January 5, 2012
This post was originally published in the Rambling Labs Blog on January 5, 2012.
As I said when announcing the Rambling Labs new site, we’ve been learning a lot of stuff while building it.
Something that we didn’t have the chance to implement on our current projects (but that we will be including soon), is adding custom error pages to the site. So far, what we were looking for was two things: a custom 404 error page and a custom generic 500 error page.
For the experience I have now with Rails, I thought this would be a piece of cake. Well, in fact… it would’ve been if we were using Rails 2. But guess what? The error handling behavior in Rails 3 is not what you would expect. Even worse, it’s broken for routing errors!
For what I could…
-
Replacing ERb with HAML on your Rails application generators
January 5, 2012
This post was originally published in the Rambling Labs Blog on January 5, 2012.
As you may know, we’ve been using HAML lately for our views.
Since I don’t plan to use ERb for my views anytime soon, I want HAML to fit in as smoothly as possible. Luckily, there is a way to replace ERb as the default generated view.
Just add this line to your
Gemfile
:gem 'haml-rails'
And you should be good to go!
Now, when you run
rails generate controller test method_one method_two
, you should see something like this:# ... invoke haml create app/views/test create app/views/test/method_one.html.haml create app/views/test/method_two.html.haml # ...
Way easier than what I thought it would be. But you know, that’s…
-
Writing elegant HTML with HAML
January 4, 2012
This post was originally published in the Rambling Labs Blog on January 4, 2012.
Another cool thing that we learned while building the new Rambling Labs site was HAML. It’s a markup language that is based on the premise that ‘Markup should be beautiful’, in their own words.
It’s very easy to install, just add
gem 'haml'
to yourGemfile
and runbundle install
. To use it, replace yourview_name.html.erb
file with aview_name.html.haml
file.Like SASS and CoffeeScript, to achieve the beauty it professes, HAML uses indentation to determine what it should do next. This means, and you guessed it, that it writes beautifully.
Compare this ERb file:
<div id="single_post"> <h2 class="post_title"><%= link_to post.title, post %></h2> <div
-
Generating your site menu with the 'simple-navigation' gem
January 3, 2012
This post was originally published in the Rambling Labs Blog on January 3, 2012.
One of the cool things I learned while building our new site was how to generate your site navigation menu without having to do the highlighting logic yourself.
There’s a great gem out there for this called
simple-navigation
, which you can find on GitHub. It’s easy to set up and use, so you will probably do what you need to do really quick. To install, add it to your rails applicationGemfile
:gem 'simple-navigation'
Then, run
bundle install
. After it’s installed, generate the configuration file for it, which will be theconfig/navigation.rb
, with the following:rails generate navigation_config
Go ahead and open the
config/navigation.rb
file, and add your…