I’m getting an error in my Rails 3 app that I can’t pinpoint the source of… When I try to destroy an object, I get the following:
NameError (uninitialized constant Outcome::OutcomeAnalyAsis): app/controllers/outcomes_controller.rb:141:in `destroy'
Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.0ms)
Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (15.6ms)
Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (15.6ms)
This is the destroy function I have. The error is because of the line that says @outcome.destroy.
def destroy
@outcome = Outcome.find(params[:id])
@outcome_tps = OutcomeTimepoint.where(:outcome_id => @outcome.id).all
@outcome_subs = OutcomeSubgroup.where(:outcome_id => @outcome.id).all
@outcome_columns = OutcomeColumn.where(:outcome_id => @outcome.id).all
@outcome_column_vals = OutcomeColumnValue.where(:outcome_id => @outcome.id).all
@outcome_results = OutcomeResult.where(:outcome_id => @outcome.id).all
@outcome_tps.each {|i| i.destroy}
@outcome_subs.each {|i| i.destroy}
@outcome_columns.each {|i| i.destroy}
@outcome_column_vals.each {|i| i.destroy}
@outcome_results.each {|i| i.destroy}
@outcome.destroy #error happens on this line
respond_to do |format|
@outcomes = Outcome.find(:all, :conditions => {:study_id => session[:study_id]})
@study_arms = Arm.find(:all, :conditions => {:study_id => session[:study_id]})
format.js {
render :update do |page|
page.replace_html 'outcomes_table', :partial => 'outcomes/table'
end
}
end
end
There is an OutcomeAnalysis class, but I can’t figure out where it’s tied to Outcome. I’ve done a search over all files in my project directory for “OutcomeAnalyAsis” and “analyasis” both case-sensitive and non. The only place it occurs is in the log file from these errors.
I know this is likely to be somewhere within my project code, but does anyone have any suggestions on what could be causing this, or where I should look? I’m trying to destroy the selected @outcome object. The id of the @outcome object is being set correctly with params[:id].
I can post more code segments if it would help. Thanks in advance!
Dude looking at your code seems that very first thing you need to use is
etc….
Once you this thing then let us know whats the problem.
it will remove your these lines of code