For some reason I seem to be unable to call methods defined in application.rb All controllers are supposed to inherit from application.rb correct? I have a bit of code that does some filtering and I want it accessible from any controller however when I try to call it, it fails. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
show how you''ve defined it in application.rb and how you''re calling from your controller. On Aug 13, 8:21 pm, Glen <DamnBig...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> For some reason I seem to be unable to call methods defined in > application.rb > > All controllers are supposed to inherit from application.rb correct? > > I have a bit of code that does some filtering and I want it accessible > from any controller however when I try to call it, it fails.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
application.rb def desired_columns(model, fields, omit = true) columns = model.constantize.content_columns.collect do | content_column| if omit for field in fields if content_column.name != field content_column end end else for field in fields if content_column.name == field content_column end end end end return columns.compact! end Here is where I''m calling it this is in a controller: def details @user = session[:user] @columns = desired_columns("User", ["salt", "hashed_password"]) end On Aug 13, 7:04 pm, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> show how you''ve defined it in application.rb and how you''re calling > from your controller. > > On Aug 13, 8:21 pm, Glen <DamnBig...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > For some reason I seem to be unable to call methods defined in > > application.rb > > > All controllers are supposed to inherit from application.rb correct? > > > I have a bit of code that does some filtering and I want it accessible > > from any controller however when I try to call it, it fails.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
that looks correct... make sure your application.rb starts with class ApplicationController < ActionController::Base and other controllers start with class MyController < ApplicationController --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I have this problem too, which I believe I have previously posted here. Still no solution. Glen wrote:> For some reason I seem to be unable to call methods defined in > application.rb > > All controllers are supposed to inherit from application.rb correct? > > I have a bit of code that does some filtering and I want it accessible > from any controller however when I try to call it, it fails.-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
what version OS/ruby/rails? i''d probably back up my project, nuke ruby and rails and reinstall them. On Aug 15, 11:53 am, Brian Ablaza <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I have this problem too, which I believe I have previously posted here. > Still no solution. > > Glen wrote: > > For some reason I seem to be unable to call methods defined in > > application.rb > > > All controllers are supposed to inherit from application.rb correct? > > > I have a bit of code that does some filtering and I want it accessible > > from any controller however when I try to call it, it fails. > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---