Topic: Class method?
I have a class method (I believe, Im failry new to this) and I am trying to access it in my controller. I can get it to work in the rails console, but in rails it gives me an argument error.
Inventory Model =>
def return_date(repair) if repair number = self.group.default_loan_period else number = self.group.repair_loan_period end number.business_days.after(Time.now) end
inventory = Inventory.find_by_asset_number(params[:asset]) if inventory date = inventory.return_date(true) @transaction_detail = TransactionDetail.new(:transaction_id => params[:transaction_id], :inventory_id => inventory.id, :due_back_at => date )
When I type the following in my rails console it works. When I try it in the rails app, it says "wrong number of arguments (0 for 1)" I checked that inventory in my controller has an object via outputting the ID in the log. I type this in the rails console and it works
i = Inventory.first i.return_date(false) => Wed, 08 Aug 2012 23:57:58 EDT -04:00 i.return_date(true) => Thu, 02 Aug 2012 23:58:35 EDT -04:00
Last edited by todd.sanders79 (2012-08-02 00:04:08)