1

https://github.com/coshx/techlunches/tree/fdb70ff65997f9のチュートリアルに従ってバニラ joosy rails アプリを作成しました

rails 側と joosy 側の両方に 2 つのリソースがあります。

# app/models/presenter.rb
class Presenter < ActiveRecord::Base
  attr_accessible :email, :github_username, :name, :twitter_username

  has_many :presentations
end

# app/models/presentation.rb
class Presentation < ActiveRecord::Base
  attr_accessible :description, :title

  belongs_to :presenter
end

# app/assets/javascripts/techlunches/resources/presentation.js.coffee
# (next line needed because this file is loaded before presenter.js.coffee)
#= require techlunches/resources/presenter
class @Presentation extends Joosy.Resource.REST
  @entity 'presentation'
  @map 'presenter', @Presenter

# app/assets/javascripts/techlunches/resources/presenter.js.coffee
class @Presenter extends Joosy.Resource.REST
  @entity 'presenter'
  @map 'presentations', @Presentation

ホームページにアクセスすると、コンソールで次の行が機能します。

>> Presentation.find(1)('presenter_id')
   1
>> Presenter.find(1)('name')
   Ben

ただし、この行は機能しません

>> Presentation.find(1)('presenter')
   undefined
4

1 に答える 1