Ember.js is a quite popular framework used for creating all sorts of web applications. The main advantage is that it lets creating pretty complex solution very quickly, which can’t but win hearts of plenty big and small IT companies. We gathered some most common mistakes Ember Beginners make to share some knowledge and help you to master this framework easier.

1. Use Controller right

Many Ember beginners mistakenly think that Ember and Rails have a lot in common. In fact, in some situations knowing how they do things in Rails might even hamper you. Yes, they both use model-view-controller, but here is where the similarities end.

Unlike Rails, Ember has Route object and Controller object. The first one is used for requesting Model and Controller is used for processing it. Ember Controller is basically used for accessing data from the Model, so you shouldn’t expect from it what you do from Rails Controller.

 

2. View also makes difference

One more thing that Ember has different from Rails is View. If you think that Ember View would display the data to the Controller, you are wrong. You should use Template for that.

But what is View in Ember for then? Well, this is quite easy. You can perfectly use them for developing reusable components as well as creating logic for handling events. So is you have an element that you need to be displayed on all pages, like e.g. Profile Avatar go ahead and use View for it.

The view can also be used for catching events, but is better to send them all to Controller for further logic.

 

3. Work with Events update correctly

Events update is another thing that Ember has different. If you are used to jQuery, you might have some hard times with Ember. Or you can simply follow our piece of advice. Unlike jQuery, Ember expects you to bind the field that should be updated to a property in your Controller and Ember will take care of updating things itself.

This way, as you probably see, Ember logic for this is the exact opposite of what jQuery does.

 

4. Don’t write extra code

Ember takes care of you much better than you can imagine. If in Rails you have a page that has now additional actions on it, you would have to create a UserController for it. For Ember this is not the case. If there are no actions, you can just have a cup of tea instead, Ember will create such UserController for you. Using the magic power if naming conventions it will do all the work for you, which can’t but add a few extra points to it. And this would happen not only with UserControllers but with Route objects as well.

 

As you see Ember is a great thing, if you know it better. Hope these tips would help you a bit mastering it.

Questions? Comments? Let’s talk about them in the comments section below.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?


Author

Business Analyst at Rubyroid Labs

Write A Comment