Created
October 30, 2013 01:27
-
-
Save dnch/7225807 to your computer and use it in GitHub Desktop.
Playing with a way of setting UI-specific default values in forms.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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