Setting up server hardware time


:~$ sudo date 093019512009
############# ddmmHHMMYYYY

:~$ sudo hwclock --systohc
:~$ sudo hwclock --show

Setting up server hardware time


:~$ sudo date 093019512009
:~$ sudo hwclock --systohc
:~$ sudo hwclock --show

Fixing IE6 & Rails & cookies issue

Problem: Cookies are not set in IE6, as well as session, which depends on cookies.

Problem description: This is caused by default IE6 security option "Block 3rd sites party cookies".

To solve the issue, you need to create Privacy Policy for your site

Here are the steps you need to do in your rails application:

1. Generate privacy policy http://www.alphaworks.ibm.com/tech/p3peditor
2. Put two files p3p.xml and policy.html into /public/w3c/
3. Add

to your apps/views/layout/application.rb
4. Add a header in application_controller.rb in before_filter the following code:
header['P3P'] = 'CP="CAO CURa ..."'

And that's it. Don't forget to clear cookies and restart your IE6.

Useful links:

http://www.oreillynet.com/pub/a/javascript/2002/10/04/p3p.html

Refactoring ruby code #2: Extracting logic to helpers

In this post I want to demonstrate an simple refactoring technique extract method.

Here is an long controller method:



It's obvious that this is not the right place for such logic. So what we do is:
1) Write some tests
2) Create EventsHelper
3) Move all logic from controller to EventsHelper
4) Rewrite test :)

Here is a result:



So, now in views we use previous_moth(@month) instead of @previous_month

What we got:
* Thiner controller
* Separate logic
* Easy testing
* Less variables