Leonel *.* wrote in post #955184: > Still same error... > > APPLICATION CONTROLLER > @company_id = company_id > def company_id > output_id = User.find_by_id(session[:user_id]).account.id > end > > ERROR > Routing Error > undefined local variable or method `company_id' for > ApplicationController:Class > > Why would it say the method is undefined, if it ISSSS defined?
Obviously it wouldn't. You're defining an instance method, and apparently trying to call it as if it were a class method. The problem is apparently in the line @company_id = company_id: since that's outside any method definition, self is the ApplicationController class, not an instance. You need to put this line inside an instance method for it to do what you want. If this is hard to understand, review the semantic and syntactical distinctions between class methods and instance methods in Ruby. > and why > would it have something to do with the routes if it's just a simple > method and a simple variable? I don't think it does have to do with routes. Best, -- Marnen Laibow-Koser http://www.marnen.org [email protected] -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

