Find, using a link instead of a form

Hello;
Here’s the latest puzzle stumping me. Seems it should be simple but
I’m feeling like a moron. I would like to have a link that, when
clicked, returns the results of a pre-set find.

Here’s the deal. I’m working on a contact management and scheduling
app for the photo studio I work for. I want our staff to be able to
create assignments (think of them as events). Most of the time when an
assignment is booked, a date and time are established. But sometimes
the date isn’t certain. Other times we find that an assignment needs
to be rescheduled but the client doesn’t yet know when.

In either of those cases, the database column “starts_at” (of type
datetime) will be empty.

I would like the user interface to have a link (something like
“Pending Assignments”) which, when clicked, would find and display all
assignments for which starts_at is empty. Or starts_at.year, or
starts_at.day or whatever.

I want this to be a link rather than a form input because the find
criteria is always going to be the same.

I installed the Searchlogic gem but can’t come up with how to get it
to do what I want.

I have an index action in the assignments_controller that basically
does an @assignments = Assignment.find(:all). Can I leverage that so
that it returns a select set if there is some criteria and all
Assignments if not? I guess the “some criteria” part is what eludes
me.

Thanks for any suggestions and pointers.

Steve

On Mon, Oct 19, 2009 at 10:12 AM, SNelson [email protected] wrote:

I would like the user interface to have a link (something like
“Pending Assignments”) which, when clicked, would find and display all
assignments for which starts_at is empty. Or starts_at.year, or
starts_at.day or whatever.

Uh, why not just create an appropriate controller method, something
like ‘pending’, and use that as the link, e.g. ‘/assignments/pending’ ?

FWIW,

Hassan S. ------------------------ [email protected]
twitter: @hassan

Thanks;

Uh, why not just create an appropriate controller method, something
like ‘pending’, and use that as the link, e.g. ‘/assignments/pending’ ?
I’ll give that a try. I’m probably over-thinking things - was trying
named_scopes and other new (to me) stuff - but probably basic is
better here?
Steve

On Mon, Oct 19, 2009 at 1:57 PM, SNelson [email protected] wrote:

Uh, why not just create an appropriate controller method, something
like ‘pending’, and use that as the link, e.g. ‘/assignments/pending’ ?

I’ll give that a try. I’m probably over-thinking things - was trying
named_scopes and other new (to me) stuff - but probably basic is
better here?

You could use a named_scope in your model – I would – and then
combine that with a custom route/controller method to invoke it.

That seems pretty minimalist :slight_smile:


Hassan S. ------------------------ [email protected]
twitter: @hassan

Thanks again.

That seems pretty minimalist :slight_smile:
I like minimalist.
Will head in that direction and shout if I fall down any holes along
the way.
Which is likely.

Steve