Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
active-model-adapter
Advanced tools
ember install active-model-adapter
This gem comes bundled with Ember
Rails. If you want to specify a
specific version in your Gemfile
, you can reference the
active-model-adapter-source
gem and it will get loaded by Ember Rails:
gem 'active-model-adapter-source', '~>1.13' # or whatever version you
need
bower install --save active-model-adapter
The ActiveModelAdapter is a subclass of the RESTAdapter designed to integrate with a JSON API that uses an underscored naming convention instead of camelCasing.
It has been designed to work out of the box with the
active_model_serializers
Ruby gem. This Adapter expects specific settings using ActiveModel::Serializers,
embed :ids, embed_in_root: true
which sideloads the records.
The ActiveModelAdapter expects the JSON returned from your server to follow the REST adapter conventions substituting underscored keys for camelcased ones. Unlike the DS.RESTAdapter, async relationship keys must be the singular form of the relationship name, followed by "_id" for DS.belongsTo relationships, or "_ids" for DS.hasMany relationships.
Attribute names in your JSON payload should be the underscored versions of
the attributes in your Ember.js models.
For example, if you have a Person
model:
// app/models/famous-person.js
export default var FamousPerson = DS.Model.extend({
firstName: DS.attr('string'),
lastName: DS.attr('string'),
occupation: DS.attr('string')
});
The JSON returned should look like this:
{
"famous_person": {
"id": 1,
"first_name": "Barack",
"last_name": "Obama",
"occupation": "President"
}
}
Let's imagine that Occupation
and Person
are just another model:
// app/models/person.js
export default var Person = DS.Model.extend({
firstName: DS.attr('string'),
lastName: DS.attr('string'),
occupation: DS.belongsTo('occupation')
});
// app/models/occupation
App.Occupation = DS.Model.extend({
name: DS.attr('string'),
salary: DS.attr('number'),
people: DS.hasMany('person')
});
The JSON needed to avoid extra server calls, should look like this:
{
"people": [{
"id": 1,
"first_name": "Barack",
"last_name": "Obama",
"occupation_id": 1
}],
"occupations": [{
"id": 1,
"name": "President",
"salary": 100000,
"person_ids": [1]
}]
}
git clone
this repositorynpm install
bower install
ember test
ember test --server
ember build
For more information on using ember-cli, visit http://www.ember-cli.com/.
FAQs
Adapters and Serializers for Rails's ActiveModel::Serializers
The npm package active-model-adapter receives a total of 19,240 weekly downloads. As such, active-model-adapter popularity was classified as popular.
We found that active-model-adapter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 15 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.