I want to call a method that i have implemented in the controller and i don''t know how to call it from the index.html.erb file. Please help. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
If you have utility methods you wish to call from views use the Rails helper convention and put them in modules under app/helpers - you can use the rails command line script to help you generate them if need be. Max On 1/25/12, ROR-new <marios_army-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> I want to call a method that i have implemented in the controller and > i don''t know how to call it from the index.html.erb file. > Please help. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 25 January 2012 22:40, ROR-new <marios_army-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> I want to call a method that i have implemented in the controller and > i don''t know how to call it from the index.html.erb file.Can you explain what sort of function this is? What is it doing? The answer to the best way to solve the problem depends on what the method does. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 26, 3:20 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 25 January 2012 22:40, ROR-new <marios_a...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote: > > > I want to call a method that i have implemented in the controller and > > i don''t know how to call it from the index.html.erb file. > > Can you explain what sort of function this is? What is it doing? The > answer to the best way to solve the problem depends on what the method > does. > > ColinBecause i am new to Rails, in need to understand better how rails work.First i have created a controller and views of the controller in netbeans.In controller i have the following code: class SayController < ApplicationController def hello // ''hello'' is name of the view, inside ''hello'' method i can create other methods and call them ONLY from the hello.html.erb or not? @items=["item1","item2" ...] // i want to create an array and show all the elements in hello.html.erb. end end Please specify if the code is correct.Also in hello.html how i can call the array or the method and show the content. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 26 January 2012 13:58, Marios Nikolaou <marios.nikolaou87-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Jan 26, 3:20 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> On 25 January 2012 22:40, ROR-new <marios_a...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote: >> >> > I want to call a method that i have implemented in the controller and >> > i don''t know how to call it from the index.html.erb file. >> >> Can you explain what sort of function this is? What is it doing? The >> answer to the best way to solve the problem depends on what the method >> does. >> >> Colin > > Because i am new to Rails, in need to understand better how rails > work.First i have created a controller and views of the controller in > netbeans.In controller i have the following code: > > class SayController < ApplicationController > > def hello // ''hello'' is name of the view, inside ''hello'' method i can > create other methods and call them ONLY from the hello.html.erb or > not? > @items=["item1","item2" ...] // i want to create an array and show > all the elements in hello.html.erb. > end > > end > > Please specify if the code is correct.Also in hello.html how i can > call the array or the method and show the content.I suggest you work through some tutorials on Rails. railstutorial.org is good and free to use online. Make sure that the tutorial uses the version of rails that you have installed. Also look through the Rails Guides. Once you have worked right through a good tutorial then you will be able answer most of your questions yourself. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.