I had this:
class ProposalsController < ApplicationController
def forkIt
return "FFFFFUUUU"
end
end
But when I tried to access the method (so I can gave my FFFFUUUU RAGE) it told me that such method was undefined.
Now, I read somewhere that i needed to make it accessible, so this came
class ProposalsController < ApplicationController
attr_accessor :forkIt
def forkIt
return "FFFFFUUUU"
end
end
This is the ruby console extract
ruby-1.9.2-p0 > @proposal = Proposal.find(4)
=> #<Proposal id: 4, title: "asda", description: "fdsfds", owner: 1, parent_id: nil, created_at: "2011-08-12 21:28:39", updated_at: "2011-08-12 21:28:39">
ruby-1.9.2-p0 > @proposal.forkIt
NoMethodError: undefined method `forkIt' for #<Proposal:0x9b11030>
But still nothing… help this Ruby noob. thanks.
You defined your
forkItmethod on on your controller,ProposalsController, but you’re calling it on the model,Proposal.You need to move
forkItto the model class.@proposal = Proposal.find(4)makes@propsalan instance of theProposalclass, not theProposalControllersclass.