Reputation:
I have a "jobs" model in my RoR project and i need the controller to access a table other than "jobs" in the database.
Calling: @var = Job.find(:all) is not problem, but calling
@var = TableB.find(:all)
gets "undefined local variable or method `tableB'" for JobsController:Class
Any ideas? Thanks!
Upvotes: 2
Views: 1598
Reputation: 2150
All models are available in all controllers.
So from your exact input I would say tableB != TableB
could be the problem.
Upvotes: 2
Reputation: 14355
Do you have a TableB model?
script/generate model TableB
You might also be trying to have a model that corresponds to a different table name (not sure exactly what you're asking):
class Job < ActiveRecord::Base
set_table_name 'TableB'
end
Upvotes: 1