But it doesn't work properly. I think: It is normal, because of new
version of Rails (2.0 and higher), where paginate is plugin now. So i
installed will_paginate by this way:
gem install mislav-will_paginate
(gem install will_paginate doesn't work too!)
And added on the end (after "end" word) in config/enviroment.rb:
require 'will_paginate'
And at least I'm looking...
Crash. Error like this:
NoMethodError in CommunityController#index
undefined method `paginate' for #<CommunityController:0x49985b4>
Yes, but I didn't understand this... I'm newb. I use now RailsSpace
book.
Will you so cool and translate to me: How can I change my code for
will_paginate, please?
Yes, but I didn't understand this... I'm newb. I use now RailsSpace
book.
Will you so cool and translate to me: How can I change my code for
will_paginate, please?
It's pretty simple. Your models gain a paginate method that is pretty
much exactly the same as find (it takes the same options
(:conditions, :order and so on) except that it also takes a :page and
And when I want to execute this code. browser gives me back:
Couldn't find Spec with ID=1 AND (last_name like 'B%')
I don't know, what exactly it's saying... I just want to paginate rows
from model Spec (which one is belongs_to :user), to show users from
databases. In Spec model I've got first_name and last_name and by
ActiveRecord this is belong to User model.
But now I've got problem - how it show by will_paginate?
RailsSpace is clearly outdated and that old "paginate" method should
not be used anymore. You're better served getting a newer book like
the latest "Agile web development with Rails".
And when I want to execute this code. browser gives me back:
Look at the will_paginate docs a little more closely. The paginate
method returns a single object and (unlike the old paginate) you don't
pass it an argument to tell it what to paginate. That error message
doesn't look like something that will_paginate would raise though.
I don't know.. I hope you can help me. I've got that code:
if params[:q]
query = params[:q]
# Najpierw wyniki spośród użytkowników...
@users = User.find_with_ferret(query, :limit => :all)
# ... a następnie podwyniki
specs = Spec.find_with_ferret(query, :limit => :all)
faqs = Faq.find_with_ferret(query, :limit => :all)
# Teraz połącz w jedną listę oddzielnych użytkowników,
posortowaną według nazwisk
hits = specs + faqs
@users.concat(hits.collect { |hit| hit.user}).uniq!
# Sortuj wg. nazwiska (wymaga specyfikacji dla każdego
użytkownika)
@users.each { |user| user.spec ||= Spec.new }
@users = @users.sort_by { |user| user.spec.last_name }
end
And here I have not any idea, how use will_paginate. Can you shot me a
solutions?