Finally the porting day has come, I only have little time but that’s better then noting. Besides if I never start, I’ll never get anything done. OK here comes nothing
rails GOSJAR
So far so good. I’ll add it to beanstalk (cool rails app for svn btw.) really quick and get on with it. My first idea was to port database from SQL2005 to MYSQL, I would have to rename a couple of tables to conform to rails pluralisation and that would be it. Then I thought best thing is to port .css and try to work my way from Wilson master pages to Rails layout page. One thing is bothering me – I have custom made tab control to switch between pages. I know there is rails plugin for this, but no clue how to use it, also I have custom breadcrums control that is working beautifully.
But there was tiny voice in my head saying: “You know you have loads of stuff in business logic that is bothering you”. Application has way too many data that no one needs and that is laying there because in the beginning we thought that it would be important. Do I really want to port that? Deep inside I knew the answer all along. Since it’s only one two lines I could not resist the urge and I ditched the whole 1:1 port idea.
rake db:create
ruby script generate Event :event_data datetime :remark string
Hmmm that’s not what I wanted… let me check the syntax
ruby script generate Event event_data:datetime remark:string fixed_date:datetime
Aaaa, it’s better I see that migrate script is generated and it’s a good sign. Let me check the script:

Looks ok to me….
Rake db:migrate
Sweet victory, events table is generated. This pluralisation was really freaking me out in the beggining but it doesn’t seem so irrationale to me now.Phew this was fun.
I think I am ready to create controller and action for list of events.
Ruby script\generate controller Events index
Btw. I am stuck on my Windows XP box for tonight, so I’ll have to ajust a bit. I’am not sure if I need to add routing to resource file or not since I did create controller. I think I have to, unless I use scaffold – and I won’t use scaffold. Hmmm it’s called routes, not resource and I don’t see any Event mentioned here. If I type http://localhost:3000/Events I get routing errors. I think that is enough hints even for me. I’ll add
map:resources :events
to routes.db file in config folder. I still am getting routing error, wait a minute why is there star in my routes.rb file in system tray, huh I forgot to save it. Ctrl-S…. Firefox…. Syntax error
MAN it was a whole lot funnier what guy made his blog site in 5 minutes…
unexpected ‘:’, expecting kEND
What does that mean? Oh I get it…
map.resources :events
Routing is working perfectly now… page is saying „Find me in app/views/events/index.html.erb“ – that’s what I wanted in the first place… It’s all great but there are two problems – application is not doing anything yet and it looks like hello world example… I would really feel better if I could get my old master page to show up in rails. I remember one presentation about how ASP.NET in VS2005 is really cool, guy slapped some grid on the screen and then dragged in professionally designed .css with some cool pictures – it was awesome and really quick. The fact that it probably took designer a couple of days to get it that way didn’t bother me at all. It was cool, period. (and fast)… and if I could only port my not so professional master page here… I would be happy.

I have a layout folder but there is nothing in it… It seems I need to create file named application.html.erb. Why did I think I’ve used Wilson master pages? I’ve used ASP.NET master page… copy paste here I come…. It’s not working I have some crappy code in it…. let me clean that up and look it up in Firefox to gloat a bit… wait it’s not looking very impressive.

I need to replace .css reference and I guess i don’t need „tabs.css“ anyhow so I’ll thow it out.
<%= stylesheet_link_tag 'style' %>
<%= stylesheet_link_tag 'layout' %>
And write a real yield, what was I thinking…
<%= yield %>
It’s now looking a whole lot better, at least to me…

BUT, where is my image, that I’ve spent five hours in photoshop to get it to look the way it looks
After some poking around I’ve eneded up putting images in public/image folder, and removing ../ from my .css when referencing images. That’s what I am talking about. Here is my master page layout.

I still haven’t figured out how to add tabs, bread cumbs and side menus but it looks better. Code is a lot cleaner and doing almost the sam thing.

So far I am thrilled… if you are wondering what I am using for reference it is wonderfull book from Partick Lenz – Simply Rails 2. If you’ve somehow managed to get through my ramblings you may have concluded that nothing is working yet – and I would have to agree on that. But for one and a half hour I am as happy as I can be. Rails seems to be helping me every step of the way, and just the fact that I threw out ton of garbage from that half-machine-generated master page is making me feel good. Not to mention my ZERO compile and VS2005 startup time