Rails form errors

I’ve been away from Rails for a long time but just recently got back to one of my old project; The Daily Deal App.

Part of this is of course creating a bunch of forms and as we all know, with forms come error messages.

What you often would do is something like this:

...

- and then have the same code for error messages in the next form and the next. But you can easily reuse these form error handlers and since you usually handle error messages the same way throughout your application using a shared file makes perfectly good sense.

So go back to your form template and add this little line instead:
{:class => 'form-horizontal'} do |f| %>

@order %>

and create a folder within apps/views/ called shared like this app/views/shared and in here you put

and there you have it, all you have to do now is put object %> into all your _form views and replace “object” with the current model your working on.

Drupal 7 node reference

Being able to create a reference between two or more nodes becomes necessary quickly when creating a Drupal site. I looked at some of the options available but found that they – like a lot of other Drupal modules – come with too many dependencies to other modules or includes so many features that I have no need for.

I decided to write my own, the only thing I need is being able to create a simple one-to-many relationship between nodes in Drupal 7.

Drupal 7 HTML5 Boilerplate Starter Kit

Drupal 7 renders a lot of HTML markup that you need to override in order to implement something like HTML5 Boilerplate. Personally I think it’s the wrong approach when Drupal renders build-in HTML which you then have to overwrite in order to slim down the resulting HTML markup – but that’s just my personal opinion.

After several Drupal projects I decided to create a Drupal 7 HTML5 Boilerplate Starter Kit, the goal is to have a starter kit so clean that it’s no sweat to implement any HTML theme without having to overwrite too many existing theming functions.

Your theme folder structure should look something like this:

theme-folder/
 - css/
   - bootstrap-responsive.min.css
   - bootstrap.min.css
 - style.css
 - js/
   - libs/
   - plugins.js
   - scripts.js
 - html.tpl.php
 - page.tpl.php
 - region.tpl.php
 - block.tpl.php
 - node.tpl.php

In order to make use of twitters bootstrap framework which I downloaded as part of the HTML5 Boilterplate you need to adhere to a simple convention:

Drupal regions = bootstrap rows
Drupal blocks = bootstrap spans

Vim indent block of code

vim is a great editor. In order to indent a block of code you can do the following:

:4>

- this would indent line no 4 by 1 tab size.

:102,203>>

- this will indent lines 102 through to 203 with 2 tabs.

Use and the result goes the opposite way

Using wget to download an entire ftp directory

wget -r ftp://tom:myPassword@ftp.example.com/var/www/ – that’s it, wget will now download recursively download all the content from /var/www on ftp.example.com

the dojo

twits

RSS Fork me…

  • An error has occurred; the feed is probably down. Try again later.
Follow

Get every new post delivered to your Inbox.