
Loading ...
December 20th, 2007 by Michal
When working with Ruby on Rails on a windows machine you will sometimes need the development console or the interactive ruby console (irb). Actually you need it quite often :) If you do so you’ll discover that special character like the tilde (~) or the {}-brackets are not supported there. Why? I don’t know but let me know if you know the reason. However, to solve this problem just create a file which has the following content:
“\M-[”: “[”
“\M-]”: “]”
“\M-{”: “{”
“\M-}”: “}”
“\M-\\”: “\\”
“\M-|”: “|”
“\M-@”: “@”
“\M-~”: “~”
“\M-?”: “?”
save this to e.g. c:\.inputrc and put the following to your irb.bat (which is usually located in c:\ruby\bin\) straight after the @echo off line:
SET INPUTRC=C:\.inputrc
Now you should be a more happier Rails dev.. At least i am. (I found this information at flip’s blog - Thanks!)
Posted in Ruby on Rails, general stuff | No Comments »

Loading ...
December 18th, 2007 by Michal
i have updated ajaxed (classic asp ajax library) to its 0.3 version. Thanks to all contributors who helped me with their feedback. Here are the updates… read more…
Posted in AJAX, ajaxed, classic ASP (VBScript) | 17 Comments »

Loading ...
December 18th, 2007 by Michal
I did check all your comments on the JSON utility class and fixed the existing bugs. The new changes are available in version 1.4 which is available for download now. I really appreciate your help by posting your comments and solutions. Most of them have been considered in the new version. Have fun and please keep me informed about new issues.
Download JSON 1.4
Posted in JSON, classic ASP (VBScript) | 3 Comments »

Loading ...
December 17th, 2007 by Michal
Today i stumbled across a nice tool called Pastie. Pastie helps you if you want to show some bits of your source code to someone else. e.g. you need some help, advice (or you just want to show off with your code). You paste an excerpt of your code and pastie saves it for under a unique URL. Then you send this URL to the person you want to show the code. The big advantage here is that the syntax is nicely highlighted … very nice for remote troubleshooting! I have created a code snippet for demonstration.

(i’ve used code sections to create more sections.)
Posted in CSS, Javascript, PHP, Ruby on Rails, SQL, tools | 1 Comment »

Loading ...
December 12th, 2007 by Michal
When it comes to testing in Ruby on Rails I tend to test every piece of its public interface. This means I test every single public method and attribute to ensure my desired functionality. Recently I’ve updated my application from Rails 1.2.5 to 2.0.1 and I was happy to have tests. None of them failed and so I knew that my application is ready to rock with the new Rails 2.0.
However, what I want to write in this article about is how to do bulk testing of each single attribute of your models. Let’s be a bit precise. Say we have a model User which has attributes firstname, lastnameand age. In order to perfectly test the User model we should write tests which …
- ensure that invalid values result in an error for the tested attribute (e.g. age -2 is invalid, so the instance should hold an error for the attribute
age)
- and valid values don’t result in an error for the tested attribute (e.g. age 20 should be fine)
Usually you should test a couple of invalid values and a couple of valid values against each attribute of your model. This can be quite a lot to code. I explain a nice approach how to speed things up and save time for the next family event. read more…
Posted in Ruby on Rails, Testing | No Comments »

Loading ...
December 8th, 2007 by Michal
Two days ago the guys at google released a brand new api. It’s called Google Chart API. and is free for approx. 50.000 requests per day. This should be enough for smaller projects ;) The interface is quite easy: You call URL’s for your desired graphs. Also the Data is passed directly via the URL as parameters. I did not have the time yet to experiment a lot with it but from the first sight it looks very professional and i will give it a try in one of my administration areas. Here is a custom made example where I illustrate the visitors of webdevbros from the past two weeks in a nice graph… read more…
Posted in google, tools | 4 Comments »

Loading ...
December 5th, 2007 by Michal
Ruby on Rails ships with a lot of predefined validations for your models. Unfortunately there is no special email validation. Even Rails 2.0 does not ship it (check the ActiveRecord changelog) yet. Because I needed it I had to write my own validates_email method. I know there are a lot of plugins but non of them suits my needs. validates_email does the following:
- checks if email is syntactically correct (using regex)
- checks if the host of the email is supported within the application. This is very important for me because I dont want ppl signing up with one-time emails from e.g. mailinator.com. (can be disabled)
read more…
Posted in Ruby on Rails | No Comments »

Loading ...
December 5th, 2007 by Michal
Using XHR within Ruby on Rails is as easy as adding up 1 and 1. We use e.g. the link_to_remote helper and point it to a controllers action. The small problem here is that the XHR actions are all available publicly. So calling the action directly within the browser works as well. I say ’small’ problem because we cannot really prevent calling them directly but we can narrow the access only to XHR calls. We want to achieve that a common request to an XHR will fail. XHR actions will only be available if the request itself is an xhr?.
The solution with a bit of Rubyism: every xhr action needs to be postfixed with _xhr. If a calling request is not an xhr then we redirect the user the home url. For this we add a simple before_filter within our ApplicationController which will check all out actions. Here is the snippet… read more…
Posted in Ruby on Rails | No Comments »

Loading ...
December 5th, 2007 by Michal
Using the ActionControllers params method directly within your models can be very risky. You know doing this: User.new(params[:user]). Someone could easily create his own form adding additional parameters and therefore updating your model without your knowledge. The reason is clear: you take all available attributes with params. This article shows some solutions to protect your forms against such injections. read more…
Posted in Ruby on Rails | No Comments »

Loading ...
November 15th, 2007 by Michal
During the past two weeks I jumped on the train of hype and started to learn (and develop) with Ruby on Rails. I have to admit that I am very impressed so far. It seems to be exactly what I need. For this reason I might blog a bit about RoR in the future.
However, the first word about Rails is devoted to “Greg Willits” who wrote an excellent article about structuring your Ruby on Rails views & layouts. read more…
Posted in Ruby on Rails | No Comments »