Inside the form_for helper, f.submit will create a different button based on the
state of the object the form is based upon. So you get Create Widget or Update
Widget, depending on whether the @widget is persisted already or not. Very nice.
Now what if my @widget was actually a reserved word, and I had masked this in my
application by creating a set of routes for the reserved word that pointed to
the actual controller. This works, for example:
resources :actions, controller: :fw_actions
resources :fw_actions
The resulting Save/Update button looks awful, though, (Create Fw action) and I
can't find any good way to override it without manually testing if the
@fw_action is persisted or not. Is there a central place in Rails 4.0.4 to
override the naming conventions used within these helpers? I've read through
the API documentation and the Rails Guides without finding any parameter I can
set to do this.
This works:
<%= f.submit (f.object.persisted? ? 'Update Action' : 'Create
Action') %>
...but it's ugly. This issue also means religiously applying the path
helpers everywhere to make the URL stay coherent, rather than being able to just
redirect_to @fw_action from the controller, or link_to @fw_action in the view. I
can recall using the i18n framework to change the labels on fields, but as far
as I can tell, that doesn't allow you to change the visible name of the
model itself. Is there another way?
Thanks in advance,
Walter
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/3C016AAE-5B16-43EE-9F88-E24739434BFA%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.