hello
how to invoke model methods in controller & vice versa
please explain with examples
advance thanx
hello
how to invoke model methods in controller & vice versa
please explain with examples
advance thanx
You shouldn’t be invoking any controllers methods from your models,
but to invoke a method from a controller on a model you do it the
same way you do in every other ruby class.
obj = ModelName.new
go from there.
Thank You,
Ben J.
E: [email protected]
hai
first of all thx to u for explaining
i did the same way like that ur qouted
even am calling the method in model
by doing
s=Shortform.price # shortform is the model class & price is the method
in it
but the error was arise error: undefine method price in shortform
am checked the spelling & am define the particular method also
but the error was arise
plz help me Mr.
Thx
Ben J. wrote:
You shouldn’t be invoking any controllers methods from your models,
but to invoke a method from a controller on a model you do it the
same way you do in every other ruby class.obj = ModelName.new
go from there.
Thank You,
Ben J.
E: [email protected]
You’re probably trying to call an instance method. So first create a new
Shortform object.
s = Shortform.new
price=s.price
Joerg
Narayana Karthik wrote:
hai
first of all thx to u for explaining
i did the same way like that ur qouted
even am calling the method in model
by doing
s=Shortform.price # shortform is the model class & price is the method
in it
but the error was arise error: undefine method price in shortform
am checked the spelling & am define the particular method also
but the error was arise
plz help me Mr.Thx
Ben J. wrote:
You shouldn’t be invoking any controllers methods from your models,
but to invoke a method from a controller on a model you do it the
same way you do in every other ruby class.obj = ModelName.new
go from there.
Thank You,
Ben J.
E: [email protected]
Thank u Joerg D.
thx very much
You’re probably trying to call an instance method. So first create a
new
Shortform object.s = Shortform.new
price=s.priceJoerg
Narayana Karthik wrote:
hai
first of all thx to u for explaining
i did the same way like that ur qouted
even am calling the method in model
by doing
s=Shortform.price # shortform is the model class & price is the method
in it
but the error was arise error: undefine method price in shortform
am checked the spelling & am define the particular method also
but the error was arise
plz help me Mr.Thx
Ben J. wrote:
You shouldn’t be invoking any controllers methods from your models,
but to invoke a method from a controller on a model you do it the
same way you do in every other ruby class.obj = ModelName.new
go from there.
Thank You,
Ben J.
E: [email protected]
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs