-1

次のコードを使用して、デバッガー ポイントでコードを使用しようとすると (Song クラスの「rating」アクセサーを使用しようとすると)、なぜ

NoMethodError Exception: undefined method "rating" for #<Class:0xb3b7db04>

それSong.instance_methodsを明確に示して:ratingおり:rating=、リストに載っていますか?

-

#songs_controller.rb
class SongsController < ApplicationController    
    def index
        debugger
        @ratings = Song.rating
    end
end

-

#schema.rb
ActiveRecord::Schema.define(:version => 20111119180638) do
    create_table "songs", :force => true do |t|
        t.string   "title"
        t.string   "rating"
  end
end

-

#song.rb
class Song < ActiveRecord::Base
    attr_accessor :rating
end
4

1 に答える 1