Displaying 20 results from an estimated 8000 matches similar to: "wrong number of arguments error"
2006 Apr 19
4
Another DRY question
I have some code working that lists only items from a particular user.
The code in my list action finds the user and then conditionally lists
only his/her items:
def list
user = User.find(session[:user])
user_id = user.id
@product_pages, @products = paginate :products, :per_page => 10,
:conditions =>[''user_id = ?'',
user.id]
2006 Apr 22
7
Expiring items
In my database I have a products table that has a bunch of attributes
(title, description, etc) including one for date_expires.
Is there a best practices method to get the database to erase the
expired items? Is that done outside RoR via Cron or something?
Else is it better to just have my app filter out anything that is
expired but still keep those records in my dbase?
--
Posted via
2006 May 14
3
Beginner question on paginate with params and conditions
I am trying to do a simple search by product name. The first page
returns fine, but when I try to go to any other pages of the search
results, I lose the original search parameters from my search form and
get NilClass errors.
Here is the code in my controller:
namesearch = "%" + params[:name].strip + "%"
@product_pages, @products = paginate :product,
2006 Apr 19
2
Filtering items within scaffold
I''m messing with the agiles store example. I added a field in my
product table (user_id) that is also a foreign key relationship via
fk_products_user
In my scaffold I''d like to list the products as usual, but only those
products from the logged in user. I assume that would be done in the
controller..
How would I extend the basic controller:
def list
@product_pages,
2006 Apr 27
5
def list - paginate question
How do I adapt this code to only list articles made by the user logged
into the session?
def list
@article_pages, @article = paginate :articles, :per_page => 10
end
--
Posted via http://www.ruby-forum.com/.
2006 Jun 21
7
acts_as_taggable and paginate?
Hi there,
I''ve been trying to paginate over a list of members that all share a tag in
common using the acts_as_taggable plugin. The regular way of paginating over
a collection doesn''t seem to work with acts_as_taggable. Here''s what my
method looks like that takes in a tag name, finds all the members that share
the tag and then displays all the members. Nothing too fancy
2006 Jan 04
8
Trying to display data from two tables
Alrighty folks, I''m really trying here, and want to succeed with Ruby on
Rails.
I''m trying to display data that is linked from two tables using the
Active Record naming conventions, as described in Agile Web book.
The stripped-down basics;
Database
drop table if exists people;
CREATE TABLE `people` (
`id` int(6) NOT NULL auto_increment,
`lastname` varchar(30) NOT NULL,
2006 Jan 06
4
"Selecting" a calculated row / Using :select in the paginate method
Hi,
I was trying to use the :select parameter to select a calculated row,
but it appears that the parameter is not picked up by the paginate method.
I want to add the following to the select statement:
timediff(now(), created_on) as age
So I tried:
@story_pages, @stories = paginate :stories, {:per_page => 10, :include
=> ''user'', :select =>
2005 Dec 19
1
<% unless params[:context] == :gallery -%> question
I have a template that is called by two different methods. I only want
part of it too show up when it is called from one of the methods. It
always shows up for me. Can someone help to point out my error? Below
is the method that should keep part of the tempate from printing, and
the relevent part of the template.
method:
def gallery
@product_pages,@products = paginate(:products,
2006 Jan 03
5
Pagination Question
Hi -
I''ve just started working with Rails, having come from a Cold Fusion
background. I''m curious how best to deal with a huge result set. For
example, I''m building an app that contains users. I''ve used
scaffolding to setup my initial pages for CRUD operations on users.
All that is great. The problem is, I''m going to end up with 1000+
users in
2006 Apr 10
9
Pagination with letter (A B C D ... Z)
Hi there,
Is there a neat and easy way to implement pagination with letters
rather than numbers eg :
A B C D ... Z
Rob
2006 Aug 03
5
Strategy for persisting row filter variables in pagination?
I have my list view filtering rows shown within the table <tr> tags like
most of the introductory tutorials do. As I''m adding a few dozen entries
I''m noticing the standard scaffolding pagination doesn''t pick up the
number of rows from the filter since it is not being passed the number
of rows returned within the scope of the filter statement.
>From a
2006 Apr 24
4
Joined search returns NIL ids
I have two models: assets and makes. Make has many assets and an asset
belongs to one make.
I am calling this part of my asset controller from a search form with
the parameters "search" (search term) and "field" (database field
heading) which then renders a partial with the search results on it.
########################################################
if
2006 Feb 07
11
breaking down a list view
I''m trying to figure out how to change the order of a list view and it''s
obvious to me that I don''t understand what I get from a simple scaffold
to know enough to alter it.
If someone would be so kind to tell me what this means ...
def list
@placment_pages, @placements = paginate :placements, :per_page => 10
end
@placement_pages, # I am guessing that this
2006 May 22
15
collection_select default selected value
Hiall,
Unfortunately I just can''t find out how to setup a default selected
value when using collection_select. My call is like so:
<%= collection_select(:consultant, :lastname, @consultants, :id,
:lastname, { :selected => @current_consultant.id } ) %>
which is not working, I debugged so far that I know that
@current_consultant.id contains the correct value.
Any tips?
cheers
2006 May 23
5
Wierd pagination problem - Unknown options: order?
I am trying to use pagination with the order option. I am following
examples I''ve seen all over the web, but I am getting an error. My code
seems simple:
def list
@upload_pages, @uploads = paginate :uploads, :per_page => 20, :order
=> ''id''
end
Yet I keep getting this error:
___________________________________________
2006 Jan 25
6
cant convert integer to string
I''ve experimented around and have ran out of ideas, here''s the message:
TypeError in True_false_questions#list
can''t convert String into Integer
RAILS_ROOT: script/../config/..
Application Trace <http://zbyte32:3000/true_false_questions/list/0#> |
Framework
Trace <http://zbyte32:3000/true_false_questions/list/0#> | Full
2005 Dec 16
13
How to pass a collection to paginate?
There must be a better way to write this code:
@project_pages, @projects= paginate :project,
:per_page => 10,
:conditions => ["account_id = ?", account]
?!
If only I could pass the sub-collection
account = ...
@projects = account.project
to paginate, instead of letting it extract it with a find :all + sql
conditions
Alain.
--
Posted via
2007 Jan 15
2
Help with with displaying a selected list.
Hello. I call a find_all_by_subject("action") which returns 2 videos
and displays them properly. But when I add @video_pages, @videos =
paginate :videos, :per_page => 10 so I can paginate the videos, it
displays ALL the videos as if I selected list videos. Can someone
please tell me what I am doing wrong? Thank you.
selectaction.rhtml
<table>
<tr>
<% x = 0 %>
2008 Feb 29
7
Moving pagination to the Model
I''m using will_paginate in a Post class method;
[code]def self.list(page)
paginate :per_page => 10,
:page => page,
:include => :user
end[/code]
I can happily use the method on my posts controller index action;
[code]
class PostsController < ApplicationController
def index
@posts = Post.list(params[:page])
respond_to do |format|