[Nitro] Help with form_to_
Jonathan Buch
john at oxyliquit.de
Wed Nov 22 16:06:11 EST 2006
Hi,
> #{form(:object => User, :action => :find_by_name) do |f|
> f.attributes
> f.submit 'Save'
> end}
>
> Now the page is displayed in the browser, but the following error is displayed:
>
> Path: /find_by_name
> No action for path '/find_by_name' on 'Hello'
I assume the form appeared as expected on the first page?
The translation you did from form_for() to form() is slightly incorrect.
#{form_for User.find_by_name( @name )}
#{form(:object => User.find_by_name(@name), :action => :update) do |f|
f.attributes
f.submit 'Save'
end}
The :action is the method which will be called when you press the submit
button. You then need to handle the request:
def update
user = User.find_or_create_by_name(request['name'])
request.fill(user)
user.save
redirect_to R(:list)
end
Or at least something along these lines. I haven't actually tested
this but it should work just like this.
Hope this helps,
Jonathan
More information about the Nitro-general
mailing list