Skip to content

Instantly share code, notes, and snippets.

@matthooks
Last active December 19, 2015 16:09
Show Gist options
  • Save matthooks/5982056 to your computer and use it in GitHub Desktop.
Save matthooks/5982056 to your computer and use it in GitHub Desktop.
<script type="text/javascript">
window.SERVICES = <%= raw ActiveModel::ArraySerializer.new(@services).to_json %>
window.SERVICE_SUBCATEGORIES = <%= raw ActiveModel::ArraySerializer.new(@service_subcategories).to_json %>
</script>
class ServiceSerializer < ActiveModel::Serializer
embed :ids, include: true
attributes :id, :name, :input_type, :placeholder
def placeholder
object.placeholder || ""
end
has_many :service_subcategories
end
ClientDashboard.Adapter = DS.RESTAdapter.extend
bulkCommit: false
ClientDashboard.Adapter.configure 'ClientDashboard.ServiceSubcategory',
sideloadAs: "service_subcategories"
ClientDashboard.Adapter.map 'ClientDashboard.Service',
service_subcategories: { key: "service_subcategory_ids" }
ClientDashboard.Adapter.reopen
namespace: 'users'
ClientDashboard.Store = DS.Store.extend
adapter: ClientDashboard.Adapter.create()
init: ->
@_super()
@loadMany ClientDashboard.Service, window.SERVICES
@loadMany ClientDashboard.ServiceSubcategory, window.SERVICE_SUBCATEGORIES
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment