>From wiki, it looks like a new record being created needs to have
:action => resource( :users )
and an existing record being updated has to have
:action => resourch(@user)
I have been making my form usable in both instances doing this:
<% path = @user.id ? @user : :users %>
<%= form_for(@user, :action => resource(path) ) do %>
... my fields ..
<% end =%>
<%= form_for @content_type, :action => resource(path) do %>
On Sun, Nov 23, 2008 at 12:48 PM, Peter <[EMAIL PROTECTED]> wrote:
>
> I'm having the same problem even using the action
>
> form_for @article, :action => resource(:admin, @article)
>
> and I get:
>
> Named route admin_article could not be generated with {:id=>nil}
>
> This works:
>
> :action => "/admin/articles/[EMAIL PROTECTED]"
>
> Running Merb stack 1.0
>
> Thanks,
>
> Peter.
>
> On Nov 10, 4:50 am, MarkMT <[EMAIL PROTECTED]> wrote:
> > A fix for that would be sweet :-)
> >
> > Mark.
> >
> > On Nov 9, 7:31 am, "Yehuda Katz" <[EMAIL PROTECTED]> wrote:
> >
> > > Merb's forms currently don't handle form_for(@obj) in a very robust
> fashion.
> > > We looked at adding automatic support for new_record? to form_for's
> (very
> > > poor) guessing logic, but it turned out to be harder than it looks
> (because
> > > the router supports alternative configurations like resources(:posts,
> > > Article)). At the moment, form_for really requires you to specify an
> action
> > > as well: form_for(@post, :action => resource(@post)) or form_for(@post,
> > > :action => resource(:posts)).
> > > We know it's not ideal, but fixing it requites a more robust effort
> than the
> > > small fix that it seems it could be.
> >
> > > -- Yehuda
> >
> > > On Sat, Nov 8, 2008 at 4:01 PM, Roland Swingler
> > > <[EMAIL PROTECTED]>wrote:
> >
> > > > > LH already has a ticket for this problem I believe.
> >
> > > > I've done a search for "form_for" and "form" in lighthouse, and can't
> > > > find a relevant ticket (doesn't mean it isn't there of course, I just
> > > > can't find it if it is).
> >
> > > > I've managed to narrow down the problem to
> > > > Merb::Helpers::Form::Builder::Resourceful#process_form_attrs , and
> > > > have the beginnings of a fix for it - current specs fail with it at
> > > > the moment though. Oddly, looking at the generated html from the
> > > > specs, the form action is "/obj/fake_model", which I don't understand
> > > > given the fixture app's config/router.rb - so a bit more
> investigation
> > > > would be needed.
> >
> > > > Should I open a ticket and post the relevant information?
> >
> > > > Cheers,
> > > > Roland
> >
> > > > On Sat, Nov 8, 2008 at 8:34 PM, Michael Klishin
> > > > <[EMAIL PROTECTED]> wrote:
> >
> > > > > 2008/11/8 Roland Swingler <[EMAIL PROTECTED]>:
> > > > >> Should I be doing something different, or is this a bug I should
> raise
> > > > >> in lighthouse?
> >
> > > > > LH already has a ticket for this problem I believe.
> > > > > --
> > > > > MK
> >
> > > --
> > > Yehuda Katz
> > > Developer | Engine Yard
> > > (ph) 718.877.1325
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---