Thanks for the response, Jordan. At least I have the feeling that
there are no simple answers to my questions.

I have no real problem with building my own specific database calls.
It's just that I was trying to stay 100% Rails normal throughout the
app, since it's my first serious Rails effort. And the API provides
about 95% of what I need, so this inconsistency between the existing
paradigms seems strange. Especially for a 1.2+ release.

The Searchable plugin idea is pretty interesting. I would envision
something like that as a sort of wrapper for the standard relationship
methods, so you could specify which relationship entities would be
search forms.

But right now, I would love a good quick fix. I'm hoping that before
the app goes live that the Rails devs will fix this, or that I will
fix it myself with a patch if I can't wait any longer. I think I can
make a simple helper script that wraps around url_for and generates
some additional params.

I'm still open to any other suggestions, of course.

- Michael


Date: Wed, 7 Feb 2007 11:57:11 -0800
From: "Jordan A. Fowler" <[EMAIL PROTECTED]>
Subject: Re: Re: Rails questions and problems
To: [email protected]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed

Michael,

I've been thinking about your original post quite a bit. I think it
would be best to have a "search" controller, which you probably
already have that intercepts any search related parameters. For
instance, you could have a basic search action as well as an advanced
search action. For both of these actions, you'll probably want to
consolidate any database interactions into a single protected method
where you then query the specific models you're trying to search
against.

Don't always think you have to stick to the "Rails way" 100%. A lot
of times, you're going to need to fall back on your best instincts
and just solve the problem. If you wanted to get really fancy, you
could write a class or plugin that you mix-in to the models you want
searchable. I'd be interested in helping you out with this further.
Let me know if this helps...

-Jordan

On Feb 7, 2007, at 11:48 AM, Michael Frederick wrote:

> Thanks for the feedback, Tom. Let me try again from a higher level.
>
> I want to make an advanced search page. Now, all the search parameters
> I'm interested in are not simply attributes of a single model. They
> may be attributes that come through many different relationships.
>
> I'm trying to use form_helpers, but they generate inconsistencies and
> bugs when combined with url_for. So, any other ideas?
>
> - Michael
>
>
>> Date: Mon, 05 Feb 2007 11:46:08 -0800
>> From: Tom Werner <[EMAIL PROTECTED]>
>> Subject: Re: [Sdruby] Re: Rails questions and problems
>> To: [email protected]
>> Message-ID: <[EMAIL PROTECTED]>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>> I think it's a problem of not understanding what you're trying to
>> accomplish. Can you explain your interface and requirements at a
>> higher
>> level. There's probably an elegant Rails solution but we need to know
>> exactly how you want it to behave.
>>
>> Tom
>>
>> Michael Frederick wrote:
>> > Sorry for the bump, but I think some of the excitement over
>> railsconf
>> > may have overshadowed my questions. :-)
>> >
>> > On 2/1/07, Michael Frederick <[EMAIL PROTECTED]> wrote:
>> >> I've been having some problems with designing an advanced
>> search page,
>> >> and how to integrate the functionality with normal Rails
>> paradigms.
>> >>
>> >> The basic approach has been to make a search object, and I have
>> done
>> >> this (for now) by using a Struct. This way, I can use the
>> >> form_helpers, and they will receive the default value of the
>> search
>> >> param corresponding to each field. Should I try and make this a
>> model
>> >> instead? Or some other type of class that will integrate well?
>> >>
>> >> So, I use form_helpers, and then I want to be able to allow
>> further
>> >> refining and reordering of the search using links. It's not
>> exactly
>> >> pagination, but it's a similar idea. But currently, with either
>> Edge
>> >> Rails or 1.2, url_for breaks on params generated with
>> form_helpers.
>> >> Specifically, it doesn't handle nested params of the form foo
>> [bar],
>> >> which is what form_helpers generate.
>> >>
>> >> I then found some helper scripts online at
>> >> http://www.marklunds.com/articles/one/314
>> >> This helps retain the correct nested params, but then there is
>> another
>> >> problem with multi-valued selects (and I guess checkboxes).
>> Instead of
>> >> generating urls like:
>> >>
>> >> index?foo[bar][]=1&foo[bar][]=2
>> >>
>> >> with url_for you get one like:
>> >>
>> >> index?foo[bar][]=1/2
>> >>
>> >> Which then is not interpreted correctly later on reentry into
>> Rails.
>> >>
>> >> So, is there a better way to handle this? I'd like to get the
>> >> multi-valued stuff working somehow. Maybe the fault lies in the
>> >> combination of the form_helpers and the url_for (and link_to), but
>> >> that would seem to be a major blemish on Rails. If I can use
>> all that
>> >> stuff, it makes all of my form elements one-liners, and very
>> easy to
>> >> read and re-use.
>> >>
>> >> Sorry for the novel-length post...
>> >>
>> >> - Michael
> _______________________________________________
> Sdruby mailing list
> [email protected]
> http://lists.sdruby.com/mailman/listinfo/sdruby
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

Reply via email to