My models are TranslationKey, TranslationValue and KeyValue.
Here is the relevant part in the log: (the last two lines are
identical inserts!)
Processing TranslationKeysController#create (for 127.0.0.1 at
2010-05-04 22:13:31) [POST]
Parameters: {“commit”=>“Create”, “authenticity_token”=>“J+dt/
qHwHkbKygh0wBPnXPLtpkb3Pb8URxGucEbpLa0=”,
“translation_key”=>{“name”=>“key1”,
“translation_values_attributes”=>{“0”=>{“text”=>“value1”}}}}
INSERT INTO translation_keys
(name
, created_at
, updated_at
)
VALUES(‘key1’, ‘2010-05-04 22:13:31’, ‘2010-05-04 22:13:31’)
INSERT INTO translation_values
(created_at
, updated_at
, text
,
language_id
) VALUES(‘2010-05-04 22:13:31’, ‘2010-05-04 22:13:31’,
‘value1’, NULL)
INSERT INTO key_values
(translation_key_id
,
translation_value_id
, created_at
, updated_at
) VALUES(16, 27,
‘2010-05-04 22:13:31’, ‘2010-05-04 22:13:31’)
INSERT INTO key_values
(translation_key_id
,
translation_value_id
, created_at
, updated_at
) VALUES(16, 27,
‘2010-05-04 22:13:31’, ‘2010-05-04 22:13:31’)
And here is the new template:
<% form_for(@key) do |f| %>
<% if f.error_messages.length > 0 %>
<%= error_messages_for :translation_key, :header_message =>
‘Error’, :message => ‘’ %>
<% end %>
<%= f.label :name, 'Key name' %>
<%= f.text_field :name %>
<% f.fields_for :translation_values do |value_fields| %>
<%= value_fields.label :text, 'Content' %>
<%= value_fields.text_area :text %>
<% end %>
<%= f.submit 'Create' %>
<% end %>