2014-08-31 30 views

回答

1

你可以把一類app/models/不繼承ActiveRecord

# find me in app/models/my_class.rb 
class MyClass 
    attr_accessor :prop1, :prop2, :prop3 
end 

使用它在這樣的控制器:

# find me in app/controllers/some_controller.rb 
class SomeController < ApplicationController 
    def index 
     @my_class = MyClass.new 
     @my_class.prop1 = "Hello" 
     @my_class.prop2 = "World" 
     @my_class.prop3 = 1 
     # etc. 
    end 
end