レール開発に関しては非常に新しいです
レール 3.2.13 / ルビー 1.9.3
私はこのモデルを持っています
class Post < ActiveRecord::Base
attr_accessible :content, :title
attr_accessor :testing
def asignar
title = "hey"
end
end
そして、Rails コンソールに移動すると:
irb(main):004:0* post = Post.new
=> #<Post id: nil, title: nil, content: nil, created_at: nil, updated_at: nil>
irb(main):005:0> post.asignar
=> "hey"
irb(main):006:0> post.title
=> nil
これは正常ですか? 属性を取得できるように、常にオブジェクトを保存する必要がありますか?