Skip to content

Instantly share code, notes, and snippets.

@dnch
Created October 30, 2013 01:27
Show Gist options
  • Save dnch/7225807 to your computer and use it in GitHub Desktop.
Save dnch/7225807 to your computer and use it in GitHub Desktop.
Playing with a way of setting UI-specific default values in forms.
class AccountsController < ApplicationController
include Authenticated
before_action :populate_default_attributes, only: %i(new)
expose :customer
expose :accounts, ancestor: :customer
expose :account
# def new omitted, thanks to DecentExposure...
private
def populate_default_attributes
account.attributes = {
country_code: customer.default_country_code
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment