Narayana Karthik
2006-Jul-17 07:38 UTC
[Rails] how to invoke model methods in controller & vice versa
hello how to invoke model methods in controller & vice versa please explain with examples advance thanx -- Posted via http://www.ruby-forum.com/.
Ben Johnson
2006-Jul-17 07:56 UTC
[Rails] how to invoke model methods in controller & vice versa
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 Johnson E: bjohnson@contuitive.com On Jul 17, 2006, at 2:37 AM, Narayana Karthik wrote:> hello > > how to invoke model methods in controller & vice versa > please explain with examples > > advance thanx > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060717/2a656226/attachment.html
Narayana Karthik
2006-Jul-17 08:17 UTC
[Rails] Re: how to invoke model methods in controller & vice versa
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 Johnson 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 Johnson > E: bjohnson@contuitive.com-- Posted via http://www.ruby-forum.com/.
Joerg Diekmann
2006-Jul-17 08:42 UTC
[Rails] Re: how to invoke model methods in controller & vice versa
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 Johnson 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 Johnson >> E: bjohnson@contuitive.com-- Posted via http://www.ruby-forum.com/.
Narayana Karthik
2006-Jul-17 09:12 UTC
[Rails] Re: how to invoke model methods in controller & vice versa
Thank u Joerg Diekmann thx very much > 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 Johnson 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 Johnson >>> E: bjohnson@contuitive.com-- Posted via http://www.ruby-forum.com/.