Gautam Kathrotiya Gautam Kathrotiya - 1 year ago 59
Node.js Question

how to config ember.js and nodejs with ruby on rails

how to config ember.js and nodejs with ruby on rails? I am getting following error,

The Broccoli Plugin: [object Object] failed with:

Error: watch ENOSPC

Answer Source

First, get running with your Rails environment.

rails new myApp

Now, clean up the Gemfile.

gem 'rails', '4.2.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'ember-cli-rails'

You can install the dependencies with bundle install.

We've got a generator from Ember gem. Let's create initializer file with that.

rails g ember-cli:init

By default, it’s configured to use an application called frontend that must live under app/frontend.

root 'frontend#index'

you may change it to

get '/*path' => 'frontend#index'

Create the controller FrontendController with index method. We'll need the view as well. Create a empty view for index method inside app/views/frontend/index.html.erb I would like to have a separate layout as well. You might want to use the default layout with other things. So create the file app/views/layouts/frontend.html.erb with below content.

<html lang="en">
  <meta charset="UTF-8">
  <%= stylesheet_link_tag 'frontend' %>
  <%= include_ember_script_tags :frontend %>

<%= yield %>

Don't forget to create the app/assets/stylesheets/frontend.css file and add it to Rails asset pipeline. Open config/initializers/assets.rb and add this line:

Rails.application.config.assets.precompile += %w( frontend.css )

We've the ember command from Node. We'll use that to initialize our Ember App.

ember new frontend --skip-git

This will create our app. Go to the frontend directory, we'd need to more npm package. also install :

`ember install ember-cli-rails-addo`

Okay, now start the server rails s

Credited to and nandovieira. Thank you guys.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download