ROR + NoMethodError (attempt to call a private method) in the controller

In my code "

NoMethodError (attempt to call a private method): application / controllers / project_evaluations_controller.rb: 94: in `Calculate '

going on. SampleCode: for Controller :: Index and Show Method not mentioned.

class ProjectEvaluationsController < ApplicationController
  skip_before_filter :verify_authenticity_token, :only => [:index, :show]
  def calculate
    @project_id = params[:id]
    @costs_last_calculated = Time.now.utc
    @total_internal_hours = 10
    @total_external_hours = 20
    @project_evaluation.update(:internal_hours => @total_internal_hours, :external_hours => @total_external_hours, :costs_last_calculated => @costs_last_calculated)
        render :action=>"show"
  end
end

Routes:

  resources :project_evaluations do
      match "calculate", :on => :collection
    end

Suggest any solution !!!

+3
source share
2 answers

updateis a private method for Active Record objects in Rails. Instead, you want to use update_attributes.

+15
source

@project_evaluation? update -, ? ActiveRecord ( , ), , , ActiveRecord:: Base -. , , , . @project_evaluation.update_attributes().

+1

All Articles