On 17 January 2012 16:38, Agis A. <corestudios...@gmail.com> wrote: > No I'm calling it from the controller, should I call it from the view? If I > try to call it from the view like this: counter_display I get
Please don't top post, insert your reply into the previous message at appropriate points. As you have done it here no-one reading this knows what question you are answer "no" to. Thanks. > > undefined local variable or method `show_counter' for > #<#<Class:0x007fdbab80c7b0>:0x007fdbab813f10> There seems to be some confusion over what the method is called. In your original post you called it display_counter, above you have called it counter_display, but the error message appears to be for show_counter. Whatever you call it you have not noted my other point, that it should be in a view helper not in the controller. In addition, which I did not say, being a view helper it should return the string to be displayed directly, so something like def display_counter( visits ) "You have visited this page " + pluralize(@visits, " times") if visits > 5 end Put it in application_helper.rb (not application_controller) if you need it from views for multiple controllers, or the appropriate view helper file if just for one controller. Read up on view helpers if you need to. 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.