Hi all,
I''m happily using "HowToReuseEditViewsForNewViews" found at:
http://wiki.rubyonrails.com/rails/pages/HowToReuseEditViewsForNewViews
There''s this comment there saying you only need the tag "<%=
auto_form %>"
when using the code below. Can somebody tell me if that will work when
extending it with model_name (some how)?
I have several new_* methods (e.g. new_contact, new_company, new_project,
etc), and I''m not going to bother with this challenge when you big guys
out
there tell me it''s a no go to develop this.
def auto_form
action = case controller.action_name
when "new" then "create"
when "edit" then "update"
else controller.action_name
end
start_form_tag :controller => controller.controller_name, :action =>
action
end
Regards,
Gerard -wanna be guru- P.
--
"Who cares if it doesn''t do anything? It was made with our new
Triple-Iso-Bifurcated-Krypton-Gate-MOS process ..."
My $Grtz =~ Gerard;
~
:wq!
The default scaffold generator uses a partial template called _form that holds all the form definition stuff that you see in the edit/create actions. It then generates a ''new'' and ''create'' template that wraps a form around that and links the correct actions to the submit. It''s simple, it''s easy, and it''s pretty DRY. If necessary you can modify the _form partial to change the layout depending on the calling action (use controller.action_name). -- Posted via http://www.ruby-forum.com/.
Kevin, I''m under the impression that you misunderstood the point somewhat. I am aware of the scaffold function, thanx for that. What I''m looking for is, as the article link shows you can have one template for multiple actions. This works for new/create and edit/update. The only difference is that a records exists in the latter case. So only one form is needed, used by 4 methods. Because I''m having multiple new methods. I''m trying to figure out if it is possible to have one form for the following methods. new_company new_contact new_project edit_company edit_ ... etc update_ ... and create_ .... Because the comment in the article shows that in the template you then only need "<%= auto_form %>" as a form start tag. Regards, Gerard. On Monday 02 January 2006 17:26, Kevin Olbrich tried to type something like:> The default scaffold generator uses a partial template called _form that > holds all the form definition stuff that you see in the edit/create > actions. It then generates a ''new'' and ''create'' template that wraps a > form around that and links the correct actions to the submit. > > It''s simple, it''s easy, and it''s pretty DRY. > > If necessary you can modify the _form partial to change the layout > depending on the calling action (use controller.action_name).-- "Who cares if it doesn''t do anything? It was made with our new Triple-Iso-Bifurcated-Krypton-Gate-MOS process ..." My $Grtz =~ Gerard; ~ :wq!