Glen
August 14, 2007, 2:22am
1
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.
Glen
August 14, 2007, 3:05am
2
show how you’ve defined it in application.rb and how you’re calling
from your controller.
Glen
August 14, 2007, 3:20am
3
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
Glen
August 14, 2007, 10:47pm
4
that looks correct… make sure your application.rb starts with
class ApplicationController < ActionController::Base
and other controllers start with
class MyController < ApplicationController
Glen
August 15, 2007, 5:53pm
5
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.
Glen
August 15, 2007, 6:30pm
6
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 A. [email protected]