undefined method

S

Sijo Kg

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
 
K

Keisuke Fukuda

Hi,

It seems this is more rails-related problem.

Sijo said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top