ruby on rails - why am i getting method undefined? -
I'm trying to call a view from a model but I get this error
undefined method # titles_by_timing for the title category: 0x0000010668db28 & gt; Why can not I get a call from Rail Console too?
[6] Pv (main)> DeliveryCost.titles_by_timing NoMethodError: 'titles_by_timing' category for the exception # method #class: 0x00000106f397b8 & gt; /Users/user/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.4/lib/active_record/dynamic_matchers.rb22: From Here Model is.
Class Delivery Cost & lt; ActiveRecord :: Base Phle_steroy: Jivit_if_jobs Ha_maya: Naukri_dilavijn_costs Ha_maiyan: jobs, the job :: _ Dilivri_ through costs DRT Kitab_ Bay_timing Swynkdo end stuff private Diif survive_if_jobs jobs.empty? The view I am trying to call it does not correspond directly to the model or controller, its name is 'job delivery cost'.
- jdc_array = (@ job.job_delivery_costs.any ?? [@ Job.job_delivery_costs, @job_delivery_cost] Fletn: [@job_delivery_cost]) - jdc_array.each do | Jdc = Simple for_form_ :: administrator, @job, jdc] = | F | - If jdc.new_record? % Tr% td = f.input: delivery_cost_id, Collection: Delivery cost. Order (: Timing) ,: label_method = & gt; : Timing ,: value_method = & gt; : ID, Label: Wrong% td = f.select: title, grouped_options_for_select (DeliveryCost.titles_by_timing)% td = f.input: cost_per_unit, label: false% td = f.input: hour_count, label: false% td = f. Input: quantity, label: wrong% td = f.submit "add", class: "btn btn-s btn-default" but should it not make any difference? Its very disappointing
You titles_by_timing is defined in the For example < / Em> and trying to use it as the class method that is causing an error. If you do it class method like DeliveryCost.titles_by_timing you should define it as follows: Def self.titles_by_timing ## Prefix with self. End of content stuff -OR-
If you want to use the titles_by_timing method, the way it is defined now For example: DeliveryCost.find (1 A method of calling should be called .titles_by_timing
Comments
Post a Comment