Help with error


#1

I am getting this error

NoMethodError in Admin#add_to_project

undefined method `find’ for #Project:0x249da88
RAILS_ROOT: script/…/config/…

Application Trace | Framework Trace | Full Trace
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/
base.rb:1501:in method_missing' ./script/../config/../app/controllers/admin_controller.rb:65:inadd_to_project’

The following code:

application.rb

private
def get_project
session[:project_in_progress] ||= Project.new
end

project_controller.rb

def new_general
@project = get_project
@general = GeneralItem.new
@general_tab = “current”
end

Get the current Project session and

add the current Object to it

def add_to_project
@project = get_project
@project.find(params[:id])
redirect_to(:action => new_license)
end

new_general.rhtml

<%= start_form_tag :action => ‘add_to_project’, :id => @project %>

Time in
<%= datetime_select (:general, :time_in) %>

project.rb

attr_reader :proj_hash

@items is an array to hold session Objects

def add_item(items)
@proj_hash << items
end


#2

Well, I added

model :project
model :general_item

to application.rb

But now I get this

NoMethodError in Admin#add_to_project

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.find

Here’s the session dump:


:project_in_progress: &id001 !ruby/object:Project
attributes: {}
errors: !ruby/object:ActiveRecord::Errors
base: *id001
errors: {}
general_item:
new_record: true
flash: !ruby/hash:ActionController::Flash::FlashHash {}


#3

where does the error occur? could you paste the line of code where the
nil.find is done


#4

as far as i know the table level operations are static methods, not
instance
methods.

@project.find

should be

Project.find

let me know if it helps.