Archives for Programming
11
MAY
Git & git-export
Posted by Adam Posted in Programming and Software 0 comments
Over the last few months there has been a lot of talk on the internet about Git – a distributed version control system which seems to be becoming ever more popular within the Rails community. Because of this, I thought I’d follow (sheep like?) the trend and look at moving some of my projects into git repositories. I have started doing this and am now a proud, fully-paid-up, member of github (a nice little git repo hosting service). I do plan to setup my own remote git “store” in the future, but for now, until I have the time to transfer all our subversion content to git – github will do nicely for my current projects.
I could go on about how git is different to SVN and so on, but this topic has been covered to death on the internet so I won’t, but, what I do want to let you see is a quick ruby script I knocked together to simulate the behaviour of svn export http://svn.domain.com/myrepo in git. This takes the form of git-export my_repo git://mydomain.com/repo.git my_branch
You can check it out in my new github account at http://github.com/adamcooke/git-exporter/tree/master/exporter.rb – I have copied it to /usr/local/git/bin/git-export so I can simply run git-export from anywhere on my system.
If your reading this and have any suggestions to improve it, please don’t hesitate to fork the repo and send it over :)
13
NOV
emate Preview #2
Posted by Adam Posted in Programming and aTech 1 comment
As discussed before, emate is our new CMS which we’re developing. In today’s preview I’m demonstrating the new multi image upload facility which allows you to easily upload lots of images into our asset library in a single upload.
21
SEP
emate Preview #1
Posted by Adam Posted in Programming and aTech 1 comment
emate is our new content management system at aTech Media. We have been developing it for a little while and are pleased to finally release a sneak preview.
This short (5 minute) quicktime movie shows some of the features and workflow for using the application. We have also included some glimpses of a demo site which is powered by emate.
Take a look at the video here and let us know what you think…
(You will need quicktime player to view this file)
20
AUG
Introducing... Railsify
Posted by Adam Posted in Programming and Railsify 6 comments
Well here we go again, another week, another site launch – this time we’re launching Railsify, a Ruby on Rails plugin directory. I started work on Saturday morning and deployed at lunchtime on Monday – talk about a quick turnaround. During this time, I designed the site, planned my implementation and actually built the site using Rails.

Railsify is an attempt to create a centralized directory of Ruby on Rails plugins, making it easier to find for new users as well as more experienced ones. It’s our/my way of giving something back to the Rails community.
Users can add their own plugins and they can also add plugins that belong to other developers. Registered users can also bookmark their favourite plugins and become fans of other users (for example, if a member has provided some cool plugins, you may wish to recommend their work to others). Anybody can register whether you’re plugin developer or just a Rails user – and, obviously, it’s all free!
Plugins are sorted into various categories (final list still to be decided) and plugins can belong to up to 3 categories at a time. All plugins have an easy to copy Rails install command so you can easily copy and paste it directly into your shell to install the plugin. A plugin can also build up comments from any registered users.
There are still a few things which we need to iron out should (hopefully) the site get busy such as implementing some sort of plugin quality checking and a way to rate plugins so more popular ones are shown higher on lists.
Railsify will also download any README and CHANGELOG files from your subversion repository and include them as part of your listing. Alternatively, you can write your own readme and change log independent of your SVN repo.
There are also some other cool features but you need to discover them for yourself. So, pop over to railisfy.com and take a look for yourself.
18
JUL
.net
Posted by Adam Posted in Programming and Business 1 comment
Just a quick entry after noticing a small paragraph in the marketing material from a company selling content management systems to schools:
Our open counsel to any school, working with any developer, would be to ask if they are working in .Net. If not, think long and hard about the problems you might be bringing upon yourself.
What gives this company the right to try and alienate anybody reading their marketing material against using anything other than .net? Unfortunately, schools will read this and believe the using a .net language is the only thing to use – this is far from the truth. Looks like we’ll need to do something about this in our forthcoming literature.
This company also doesn’t seem to have got to grips with the use of CSS for layout as their example sites are built in tables and have multiple validation errors. Also, most of these sites have an annoying and tedious flash intro before the homepage is even visible. For a company charging circa. £4000 per month for a website, this is extremely poor in my opinion.
16
JUL
Why we switched from Swipe to Rails...
Posted by Adam Posted in Programming and aTech 0 comments
Firstly, you might be wondering what Swipe (or Rails) is. Swipe is the aTech Media developed framework which was based on our own MOAT principles (modules, object, action and template) and was written in PHP5.
Advantages of using Swipe- developed on PHP, therefore easy to deploy sites onto standard hosting environments
- in-depth knowledge of the framework as it was coded by ourselves
- closed source therefore reduced security implications
- easy to encode projects using the ioncube encoder
- not very flexible
- no third party plugins available, everything needs to be coded manually
- complicated deployment process involving standard subversion updates and checkouts on the remote server
- duplication of code
On the other hand, Ruby on Rails is a highly dynamic and flexible open source framework written in Ruby (rather than PHP) based on MVC principles (model, view, controller) and DRY (dont’ repeat yourself).
Advantage of using Rails- large number of third party plugins available
- easy deployment recipes using capistrano
- highly flexible
- no code duplication
- when selling to clients, they can be uneasy about using a relatively new framework and perceived lack of Rails developers in the UK
- deployment on a non thread-safe web server such as Mongrel can cause some issues under heavy load unless addressed
- not as much in-depth knowledge of the framework “gotchas”
- open source leads to more possible security implications (although not a problem is addressed)
“Can’t live without” features in Rails which wern’t in Swipe
I’m first to admit that Swipe was a long way behind Rails. Was anyone not expecting this? It had about 4 months of development from a sinhle developer behind it whereas Rails has many years and many developers. The list is just some of the brilliant features of Rails which we couldn’t live without:
- RJS templates for AJAX functionality
- built-it page and fragment caching
- wide variety of useful plugins
- integration with protoype and scriptaculous
- rake tasks
- capistrano
- and many more features
We now use Rails for all our new work and are even moving some PHP sites and projects over to Rails to make our lives easier.
12
APR
Rails Sessions Screencast
Posted by Adam Posted in Programming 0 comments
This is my first ever published screencast. I’m pleased to introduce a quick guide to saving your Rails sessions in a database and a quick introduction to using sessions in Rails.
This is aimed at the Rails Beginner.
Firstly, I need to apologise for some of the poor sound quality. I will work on producing higher quality audio next time.
The software used in the screencast is: e-texteditor (beta), Navicat, Firefox and PuTTY SSH Client.
07
APR
Changing the Default Form Error Markup in Rails
Posted by Adam Posted in Programming 0 comments
When I first started using Rails I was puzzled why when submitting a form as an object, any field with errors where enclosed inside a <div> rather than an inline tag such as <span>. If you add <div>s around your field this may affect your website’s output by pushing anything next to your field onto a new line (outside the new DIV block).
Now, there are two ways you can resolve this issue.
1) You can add a CSS selector for #fieldWithErrors to set the display type to ‘inline’:
#fieldWithErrors { display:inline; }
2) As this is Rails, we can easily just change the markup which is output. We do this by modifying the ActionView::Base controller in our config/environment.rb file. Simply add the line below to this file to change the markup to use <span> tags insted of <div>.
ActionView::Base.field_error_proc = Proc.new {|html_tag,instance|%(<span class="fieldWithErrors">#{html_tag}</span>)}
Personally, I recommend the second option.
05
APR
Migrations in Rails
Posted by Adam Posted in Programming 0 comments
This post is follow on from a recent post of mine on RailsForums and it outlines some of the slightly more advanced methods of using migrations in rails.
Foreign Keys
You can’t directly set foriegn keys with migrations (yet), although you can add a SQL command to a migration for FK using:
execute "alter table table_name add constraint fk_name_of_fk /
foreign key (field_name) references foriegn_table(id)<
There is a plugin which handles this fully if you need it. Here.
Primary Keys
Primary Keys can be set using:
create_table :table_name, :primary_key => "field_name"
You simply need to add the primary_key to the create_table call. Rails by default will add an id field as the primary key. This option overrides that primary key.
If you change your primary key don’t forget to tell your model about the new one using self.primary_key = “whatever"
NOT NULL
t.column :field_name, :type, :null => false
This should be specified in your model using validates_presence_of as well
Unique
Unique should really be handed within your model rather than at a SQL level – using validates_uniqueness_of inside the model.

