View rest_adapter_config.coffee
DS.RESTAdapter.configure("plurals",
galleries: "galleries" # If your model is called App.Galleries
gallery: "galleries" # If your model is called App.Gallery
)
View router.coffee
locationToUse = if window.history.replaceState then 'history' else 'hash'
App.Router.reopen
location: locationToUse
View app_router.coffee
App.Router.map ->
@resource 'portal', ->
@route 'dashboard'
@resource 'developers', ->
@resource 'messages', ->
@route 'inbox'
@route 'hidden'
@resource 'sysops', ->
View models.coffee
App.User = DS.Model.extend
#...
addresses: DS.hasMany(GleichklangWeb.Address, { embedded: true })
App.Address = DS.Model.extend
#...
user: DS.belongsTo(GleichklangWeb.User)
View store.js.coffee
When I try to find a model in the console, i get an error.
MyApp.User.find(98)
> TypeError: Object Ember has no method 'merge'
View breadcrumb.handlebars
<!---- Version 1 with #each -->
<ul class="breadcrumb">
{{#each view.breadcrumbElements}}
<li><a {{action lastObject href=true}}>{{firstObject}}</a><span class="divider">/</span></li>
{{/each}}
</ul>
<!--- Version 2 with custom helper -->
<ul class="breadcrumb">
{{renderBreadcrumb view.breadcrumb}}
View base_menu_view.js
App.BaseMenuView = Ember.View.extend{
statesForActiveCheck: [],
init: function(){
this._super()
this.get('statesForActiveCheck').forEach(this.addActiveCheckMethod, this)
},
addActiveCheckMethod: function(statePart){
functionName = statePart.replace('.', '_').camelize() + 'Active'; // the function name for 'account.settings' should be 'accountSettingsActive'
View new_trophy_route.rb
class NewTrohpyRoute
def self.matches?(request)
trophy_id = request.params[:trophy_id] # Not sure if you can get the params this way
return NewTrophy.where(:id => trophy_id).count > 1
end
end
View gist:948896
class Object
def arrayify
[*self]
end
end
View get_posts_example
<posts>
<post>
<attr></attr>
<comments>
<comment> ... </comment>
...
</comments>
</post>
</posts>