NeoVe
NeoVe

Reputation: 3897

Deprecated {{view}} on Ember 2.0 - Rails 4

I recently updated a Rails 3.2 to Rails 4.1.0

I have the ember.js for data binding on it.

This is my Gemfile

source 'https://rubygems.org'

#gem 'rails', '3.2.12'
gem 'rails', '4.1.0'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails'
  gem 'coffee-rails'
  gem 'zurb-foundation'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby

  gem 'uglifier'
end

gem 'jquery-rails'

group :development do
  gem "better_errors"
  gem 'annotate'
  gem 'pry'
  gem 'sqlite3'
end

group :production do
  gem 'pg'
end

gem 'ember-rails'
gem 'ember-source'
gem 'handlebars-source'
gem 'active_model_serializers'
gem 'filepicker-rails'
gem 'execjs','2.5.2'
gem 'therubyracer'

gem 'thin'
gem 'unicorn'
gem 'capistrano'
gem 'simple_form'
gem 'devise'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

# File upload extension
gem "paperclip"

# Admin
gem 'activeadmin', '1.0.0.pre1'

I never had this deprecation issue before, when it was on Rails 3.2

Now every time I run the app it throws this error:

Barber::PrecompilerError at /
. Compiler said: Error: Assertion Failed: Using `{{view}}` or any path based on it ('_lineItem' @ L1:C0) has been removed in Ember 2.0

I'm fairly new to ember, so I'm kind of lost on this one.

It happened only after upgrading my Rails version.

This is the file in question:

_lineitem.hbs
{{#view 'lineItem' content='lineItem' class='row collapse'}}
<div class="name columns">
  <h6>{{lineItem.name}}</h6>
</div>
<div class="qty text-right columns">
  <h6>qty: {{lineItem.quantity}}</h6>
</div>
{{#if editing}}
  <div class="taxable columns text-right">
    taxable {{view 'checkbox' checked="lineItem.product.taxable"}}
  </div>
{{/if}}
<div class="line-total columns">
  <h6>
    {{#if editing}}
      {{input value="lineItem.priceCents"}}
    {{else}}
      <span class='money'>
        ${{money-display lineItem.lineItemTotalCents}}
      </span>
    {{/if}}
  </h6>
</div>
<div class="edit columns text-right">
  <button class="button small"{{action 'removeLineItem' lineItem target="view"}}>-</button>
</div>
{{/view}}

There's maybe some other file with this kind of declaration {{view}}

Please, any ideas?

Thanks in advance!

Upvotes: 0

Views: 250

Answers (2)

GerDner
GerDner

Reputation: 409

You can turn on legacy views via an ember addon or config values.

https://github.com/emberjs/ember-legacy-views

The addon sets some config values and views will be back. Then you have the time to migrate to components.

The same approach works for legacy controllers (ArrayController etc.)

Upvotes: 1

Remi Smirra
Remi Smirra

Reputation: 2539

Since you are on Ember 2.0, I recommend turning your your view into a component called line-item.hbs in your component folder that has the following content:

<div class="name columns">
  <h6>{{lineItem.name}}</h6>
</div>
<div class="qty text-right columns">
  <h6>qty: {{lineItem.quantity}}</h6>
</div>
{{#if editing}}
  <div class="taxable columns text-right">
    taxable {{view 'checkbox' checked="lineItem.product.taxable"}}
  </div>
{{/if}}
<div class="line-total columns">
  <h6>
    {{#if editing}}
      {{input value="lineItem.priceCents"}}
    {{else}}
  <span class='money'>
    ${{money-display lineItem.lineItemTotalCents}}
  </span>
{{/if}}
  </h6>
</div>
<div class="edit columns text-right">
  <button class="button small"{{action 'removeLineItem' lineItem target="view"}}>-</button>
</div>

Then in your template file that should use the lineItem

{{line-item item=lineItem}}

Upvotes: 1

Related Questions