On May 28, 7:10 pm, egervari <ken.egerv...@gmail.com> wrote:

>
> I'm also not comparing a framework to a language. I think Ruby allows
> for these problem to happen, and the design of Rails exploits it in a
> bad way.
>
Well you do keep comparing Rails to Java. I'm sure equivalent
interfaces could be implemented in Java. You'd end up overloading
methods more explicitly than with ruby but if your goal is to guess
what other overloaded forms exist without looking at the docs I don't
think that would help.

> For example, form_for() is very troubling beast. I am just point this
> one out among countless other examples - it's just one arbitrary
> example from a bag of many.
>
> Let's say you put a controller into a namespace, you must go from:
>
>     form_for(@company)
>
> to:
>
>     form_for([:my_namespace, @company])
>
> Intuition may have suggested this:
>
>     form_for(@company, :namespace => :my_namespace)
>
> The changing of the argument from an object to an array is non-
> intuitive. I admit it's nice and easy, but it's only valuable if you
> *KNOW* it. One cannot "guess" this. I don't see how.

It's perhaps easier to understand when you know how form_for works -
like link_to, redirect_to etc and countless other bits of rails that
create urls from objects, it funnels everything though polymorphic_url

>
> There are all sorts of problems like this. For example if you have a
> @user, but it's actually a subclass, form_for() will use the model's
> name, not the instance variable's name. This is NOT intuitive. When I

Well to me it would be extremely unintuitive if a method could know
the name of the instance variable that happened to contain one of the
arguments it was called with.

> first starting to use rails, I would scratch my head wondering why
> it's trying to send params[:admin] and not params[:user] even though
> the form variable was @user.
>
> Again, the solution is this:
>
>     form_for(@user, :as => :user)
>
> This kind of thing is not intuitive. Who in their right mind would
> ever search for "as" in google in order to achieve this goal? Not me.
> It took me 4-5 hours to find the answer to this problem. I am not
> kidding. I searched everywhere, asked questions on Stackoverflow,
> asked questions here... I didn't get the answer until Carlos simply
> told me.

It's in the documentation for form_for - it's where I would have
started.

Fred

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to