Undefined method

Hi
This is more ruby related that is why I am asking here
I have controller code as
@sd_activities=ServiceDeskActivity.find_all_by_service_desk_ticket_id(service_desk_ticket.id).display_sd_activities(params[:page])

and in model ServiceDeskActivity
def self.sd_activities_paginate(page)
paginate :per_page => 2, :page => page
end

But this gave me an error
undefined method `display_sd_activities’ for #Array:0xb7416164

And if it were
@sd_activities=ServiceDeskActivity.find_all_by_service_desk_ticket_id(service_desk_ticket.id).paginate
:per_page => 2, :page => page
or
@sd_activities=service_desk_ticket.service_desk_activities.paginate
:per_page => 2, :page => page

     Then no error happens And it working properly

But
@sd_activities=service_desk_ticket.service_desk_activities
puts @sd_activities.class
@sd_activities=ServiceDeskActivity.find_all_by_service_desk_ticket_id(service_desk_ticket.id)
puts @sd_activities.class

Here both gives Array.The why the first working and second not?

Thanks in advance
Sijo

Hi,

It seems this is more rails-related problem.

Sijo Kg wrote:

Hi
This is more ruby related that is why I am asking here
I have controller code as
@sd_activities=ServiceDeskActivity.find_all_by_service_desk_ticket_id(service_desk_ticket.id).display_sd_activities(params[:page])

and in model ServiceDeskActivity
def self.sd_activities_paginate(page)
paginate :per_page => 2, :page => page
end

You defined ‘sd_activities_paginate’ as a ServiceDeskActivity’s class
method, not as Array’s instance method.

But this gave me an error
undefined method `display_sd_activities’ for #Array:0xb7416164
Because Array class does not have such method.

Cheers

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs