ruby on rails - will_paginate throug Individual Users Posts -
i users able paginate through own posts (scheduling emails). in advance can or steer me in right direction!
emails have different categories, scheduled , pending. have 2 scopes these in emails model.
email.rb scope :pending, -> { where(email_pending: true) } scope :approved, -> { where(email_pending: false) } i'm using devise organize users. in users controller have users#show action , i'm pulling user's emails this.
users_controller.rb def show @emails = @user.emails end then in view list each category of email this.
users#show <% @user.emails.approved.each |email| %> -----stuff------ <% end %> same thing goes pending. so, paginate (using will_paginate) tried.
users_controller.rb @emails = @user.emails.approved.paginate(page: params[:page], per_page: 5) and in view added.
users#show <%= will_paginate @user.emails.approved %> i tried few other things, pretty guessing , trial , error... nothing worked.
thanks again help! please let me know if needs more information me.
-kraymer
if in show method of users_controller have
@emails = @user.emails.approved.paginate(page: params[:page], per_page: in view need use @emails created
<% @emails.each |email| %> ..... <% end %> <%= will_paginate @emails %> since accessing @user.emails.approved not looking @ paginated version, original active relation.
Comments
Post a Comment