Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Rails STI and Polymorphism in Ember JS

If you have MODEL_FACTORY_INJECTIONS enabled you will not be able to use subclasses as the prototype based inheritance checks fail Issue #5573 and Issue #2342 and Issue #2316.

I found doing STI at the model layer with Ember.Data and indeed Ember.Model is not really workable for the following reasons:

  1. Each model subclass is a separate collection as far as the store is concerned.
  2. Becasue of 1. you can't query the store to get an aggregated set of results which includes all (or only some) subclasses. You could in theory workaround this by querying the store for each of the desired subclasses and merging the result using Ember.computed.union() / Ember.computed.uniq() but its not going to be efficient.
  3. Ember cannot dynamically extend object instances with mixins that have properties, which would be another way to handle STI by extending a model instance based on the type attribute in the model data.

So what you're left with is to treat things kind of like you do in the DB on your server, that is support all possibilities in your data model. This means just define all possible relationships and attributes.

When it comes to validation and other business rules, controllers can provide the fa├žade you need. The Ember way is for controllers to decorate models and you can certainly create different classes of controller to decorate models how you please.

Categories : Ruby On Rails

Related to : Rails STI and Polymorphism in Ember JS
How can Ember Rails templates be kept from leaking into the browser?
No you're not missing anything, that is how Ember works out of the box. Is there a way around that behavior? Probably. But before you try to work around it, you should seriously consider whether it's really worth it or not. Do you really care if somebody has the HTML template for your site? If your security is set up right, you shouldn't care. But if you do care, here's what I might do: Set up r

Categories : Javascript
Ember Rails back button doesn't render template even without nested routes
Well, eventually, I ended up removing turbolinks. I am still a bit unsure about doing so, but it doesn't seem to hamper my application in any way yet. To do so, you would have to remove the turbolinks gem, the 'require turbolinks' line in application.js and the turbolink tags in application.html.erb. I'm crossing my fingers hoping that didn't mess anything up that I haven't seen.

Categories : Javascript
Trying to use jsonp with ember-data, and unable to use Ember App's store.createRecord in custom adapter
This parsing of the response seems more like a job for the RESTSerializer than the RESTAdapter(though you will still need the adapter if you need to set the dataType/url) Not 100% sure, but it looks like your reponse is an array that doesn't have the correct key as stated in the documenation? If this is the case, you'd want to create a serializer for events like this App.EventsSeria

Categories : Ember Js
Ember can't find template when I provide a custom templateName to a View in Ember-CLI
In the Ember-CLI world, you want to use the ES6 import syntax, and supply your template to the View's template property: // app/views/my-view.js import Ember from 'ember'; import Template from 'app/templates/my-template'; export default Ember.View.extend({ template: Template });

Categories : Ember Js
Mocking models for testing Ember.easyForms input component inside another ember component
The problem seems to be that you are using content. in your paths optionLabelPath="content.siteLabel" which is thinking about controller proxing to a model. But your test are using the models directly -undecorated by a controller- and they do not have a content property.

Categories : Ember Js
Recently Add
Groups and Users has many oder has many through?
Rails format specifier differences
Capistrano can not create symlinks: file exist
Admin can't delete users. Ruby on Rails 3 - Michael Hartl
Don't show user name who create post
Using Wicked with Devise (2 step signup process)
RubyOnRails Rake test failures
Rails session start event handler
Why ActiveModel::ForbiddenAttributesError error?
How can i track the issue in production RAILS
Cannot install spree gem - ERROR: invalid gem: package is corrupt
Why are the nested resources for Devise authentication not working?
Rails Devise - how to open access to the site root
Rails: respond_with the same template for two methods
rails with postgresl database "role postgres does not exist"
Instance variable in Rails helper not set
Monkey patch rails 3.2 rake task
Rails_admin: Should I have admin_user or user with admin role to manage users and admin panel
undefined method `attachments' for nil:NilClass
Memory usage increase with Ruby 2.1 versus Ruby 2.0 or 1.9
Can a Rails app be deployed without using Heroku Toolbelt? If so, how?
Enable random access to collection with MongoDB
libmysqlclient-dev installation fails
undefined method `name' for nil:NilClass. Can't find but @followed is set
Allowing an arbitrary domain and subdomain in session_store.rb
Pushmeup Gem - Can't send push notifications in Active Admin model
Rails console does not start
GitHub Import: Could not locate Gemfile
AWS::S3::PermanentRedirect in SongsController#index "The bucket you are attempting to access must be addressed using the specified endpoint"
automatically create ActiveRecord parent for association
© Copyright 2017 Publishing Limited. All rights reserved.