我有一個名爲Action的模型。它看起來像這樣:在Rails中,當我在新模型中調用函數時出現NoMethodError
class Action < ActiveRecord::Base
def register_action(email,type)
@action = new()
@action.guid = "123456789"
@action.email = email
@action.action = type
action.guid if @action.save
end
end
如果我嘗試從我的user_controller訪問這個類,我得到一個錯誤。 我試圖使用的代碼是:
if (@User.save)
guid = Action.inspect()
guid = Action.register_action(@User.email,"REGISTER")
MemberMailer.deliver_confirmation(@User,guid)
end
Action.inspect()正常工作,所以我猜測,Action類可以看到,但它調用register_action行返回以下錯誤:
NoMethodError in UserController#createnew
undefined method `register_action' for #<Class:0x9463a10>
c:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:1994:in `method_missing'
E:/Rails_apps/myapp/app/controllers/user_controller.rb:32:in `createnew'
我在做什麼錯?
我是Rails的新手,所以很抱歉。