Skip to content

Instantly share code, notes, and snippets.

@denishaskin
Created October 1, 2014 23:27
Show Gist options
  • Save denishaskin/d97455e6f91e58c4f96d to your computer and use it in GitHub Desktop.
Save denishaskin/d97455e6f91e58c4f96d to your computer and use it in GitHub Desktop.
ordering fields_for
def edit
@agency = Agency.find(params[:id])
# add comments for locales that don't have comments yet, so we can present fields to the user
(I18n.available_locales.map(&:to_s) - @agency.comments.pluck(:locale)).each do |loc|
@agency.comments.build locale: loc
end
end
= simple_form_for @agency do |f|
= f.simple_fields_for :comments do |c|
= c.input :comment, label: "#{c.object.locale} comment:"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment