I got my call index view to only display the calls for the curren_user
but it does not paginate them into pages.
I want 4 per page as noted in my model but all of the calls show on
the first page. Can anyone notice why
i changed the view line <% for call in @calls %>
to
<% for call in @current_user.calls %> and then the link which works
fine but then when I have the
<%= will_paginate @calls %> it messes up
Any Ideas would be greatly appreciated
Owen
On Jul 13, 5:06 pm, THEBIGO
<Mowenh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I''m still a newb but having fun - Any help on this problem will be
> much appreciated.
> I have mymodel Call.rb
>
> class Call < ActiveRecord::Base
> belongs_to :user
> has_many:visits, :dependent => :destroy
> has_many:visits do
> def latest
> find :all, :order => ''id DESC'', :limit
=> 3
> end
>
> def all_latest
> find :all, :order => ''id DESC''
> end
> end
> def self.search(search, page)
> paginate :per_page => 4, :page => page,
> :conditions => [''name like ?'',
"%#{search}%"],
> :order => ''name''
> end
> end
>
> And my controller for CallsController with index action
>
> class CallsController < ApplicationController
> before_filter :login_required, :only =>
> [ :new, :create, :show, :index, :list, :all_show, :edit, :update, :delete ]
>
> def index
>
> @calls = Call.search(params[:search], params[:page])
>
> end
>
> my view page for index is
>
> <% form_tag calls_path, :method => ''get'' do %>
> <p>
> <%= text_field_tag :search, params[:search] %>
> <%= submit_tag "Search", :name => nil %>
> </p>
> <% end %>
>
> <% for call in @calls %>
> <%= link_to h(call.name), :action => ''show'',
:id => call %>
> <% end %>
>
> <br />
>
> <%= will_paginate @calls %>
>
> And what happens is that the paginate shows all the calls in the
> database for all the users but I only want
> it to paginate the current users calls. I''ve tried all sorts of
> things but not sure what to do. any suggestions will be
> appreciated. if you need more of my code let me know. I used the
> rails cast and obie Fernandez book and
> looked on line
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---