Actions Up

Now you have an action to set the flash-alert to display the appropriate message. You just need to pass the action some data. That data will be an object with keys for alertType and message.

The alertType will be a part of both the message and the style with Bootstrap alert variants: "success", "warning", "info", or "danger". Calling the action from a controller will look like this:

this.send('flash', {alertType: "success", message: "You Did It! Hooray!"});

You will be adding the call to the application action after creating a new sighting. In app/routes/sightings/new.js, add the following:

...
    create() {
      var self = this;
      this.get('sighting').save().then(function(data){
        self.send('flash', {alertType: "success", message: ...

Get Front-End Web Development: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.