Enough rails for me

That's it, I've had enough of Ruby on Rails!

I like the rails part, it's a very clever approach, but I really dislike the Ruby part!

The final straw occurred yesterday. It's very common in OOP to have the constructor set default values for your object just in case the consumer of your class does not set them. In C# I would do something like this.....

public class Post : MyBaseClass
{
private bool isPost = true;
}

In Ruby I was trying to achieve this simple behaviour...

01: IsPost is set to true
02: A form is displayed with the default value
03: User changes the value
04: My Post instance is updated with the values from the form

I tried to override Initialize() only.

def Initialize
super
is_post = true
end

Now Post.new(params[:post]) is not reachable for some reason.


So in my Post class I did this

def Initialize(* params)
super(params)
is_post = true
end

The problem here is when I try to initialize the values from the form in my controller class.

post = Post.new(params[:post])

This means that the super(params) is called (which sets is_post to the value in the form) and then sets is_post = true. So my value is always true regardless of what the user enters.

So I tried putting "is_post = true" before the call to super, but that throws a null reference exception.

Finally someone told me to merge hashes like this

{:is_post => true}.merge(params);
super(params)

I don't recall the error, but that didn't work either.


I'm sorry, but ANY language that gives me this much hassle just to set a default is not worth it.

C# on rails, now *that* would be nice!

Comments

Anonymous said…
Have you checked out MonoRail ?

http://www.castleproject.org/monorail/index.html

Thats mvc.
Anonymous said…
Peter I have a doubt Rubby and Rail is something like ECO + Asp.net?


kind regards
Frank
Frank

I really liked the "Rails" approach. It took urls in any form (but mainly controller/action/id) and produced a page for it, e.g.

http://host/article/read/24

This would execute the method "read" in a controller class named "article", passing it article id 24.

The controller wouldn't generate any HTML though. Instead it just set up the data needed, e.g.

@articles = article.find(:all)

Then a view would be rendered in views/article/read.rhtml - this rhtml would have ruby script embedded in it (like PHP still does), but this code was only for presentation, unlike the controller which is only for logic.

In RoR you are 100% in control of the output HTML so you can have more than 1 form etc.

That's the Rails part. I didn't like the Ruby language very much!

Active Record (the persistence framework) was nowhere near as flexible as ECO.
Anonymous said…
Thanks for the info, Peter today do you think the rubby and rails is this so mature like ECO + Asp.net?

I have this trouble, I need to run my app in several database, Eco can help me in it, I need to run the app in linux, Eco don't help me in it, I don't know if in ECO IV the suport to mono is better, for that I am exploring other technology like, php, rubby and rail, cold fusion, any advice is welcome.

regards
Frank
Hi Frank

The Rails part (akin to ASP .NET) is really nice, but the rest I do not like.

People keep telling me "mono" but I haven't tried it yet.

Someone also suggested MonoRails (from Castle) but I haven't had a chance to look at that either.

I know little of ColdFusion, but my friend used to develop it professionally, he wasn't happy that it was rewritten in Java.

PHP I didn't like, but that was a long time ago. I have heard there are Rails-like approaches for PHP but I haven't looked into it.
ReinH said…
This is what happens when someone who doesn't know the underlying language tries to hack a complex system built on top of it. Things break that they are not equipped to understand or solve and they incorrectly blame the language itself, which is irresponsible. http://blog.hasmanythrough.com/2007/1/22/using-faux-accessors-to-initialize-values addresses this issue, btw.

Popular posts from this blog

Connascence

Convert absolute path to relative path

Printing bitmaps using CPCL