[Rails-core] #3136 - Country codes in country_select

2005-12-08 Thread Jerrett Taylor
http://dev.rubyonrails.org/ticket/3136

Simple patch, but in following with others I figured I'd post a quick
email to this list.

All this does is adds functionality of country_select to allow people to
build country select boxes that use country codes. It doesn't modify
default behaviour, and the test suite has been updated.

I've seen a few people trying to figure out how to do this, and after
running into the need for it on three separate apps I just went ahead
and made the patch for it... Got sick of carting around a big array of
countries/country_codes from app to app.


Also, should things like this be posted to this list, or just left in
trac? I've noticed the ticket has already been seen/updated, so perhaps
a notification to the list is not necessary for such minor patches.
Thoughts?

___
Rails-core mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-core


[Rails-core] Why is AR::Base#sanitize_sql protected ?

2005-12-08 Thread Francois Beausoleil
Hi !

I have an instance where I'd like to use the automatic value quoting
that sanitize conditions provides.  Here's the SQL:
SELECT COUNT(*) FROM tournaments
  INNER JOIN entries ON entries.tournament_id = tournaments.id
  INNER JOIN plays ON plays.entry_id = entries.id
  WHERE #{self.class.sanitize_sql([conds.join(' AND '), values])}

Unfortunately, I get a NoMethodError because sanitize_sql is protected.

Is there a particular reason why this is protected ?

Thanks !
--
François Beausoleil
http://blog.teksol.info/
___
Rails-core mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-core


Re: [Rails-core] Why is AR::Base#sanitize_sql protected ?

2005-12-08 Thread Michael Koziarski
On 12/9/05, Francois Beausoleil <[EMAIL PROTECTED]> wrote:
> Hi !
>
> I have an instance where I'd like to use the automatic value quoting
> that sanitize conditions provides.  Here's the SQL:
> SELECT COUNT(*) FROM tournaments
>   INNER JOIN entries ON entries.tournament_id = tournaments.id
>   INNER JOIN plays ON plays.entry_id = entries.id
>   WHERE #{self.class.sanitize_sql([conds.join(' AND '), values])}
>
> Unfortunately, I get a NoMethodError because sanitize_sql is protected.
>
> Is there a particular reason why this is protected ?

Usually methods are marked as protected when we don't want to make
them part of the public API.   Every time someone calls our
'implementation' methods we either break their applications, or lose
the option to refactor that code.



--
Cheers

Koz
___
Rails-core mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-core


Re: [Rails-core] Why is AR::Base#sanitize_sql protected ?

2005-12-08 Thread Francois Beausoleil
2005/12/8, Michael Koziarski <[EMAIL PROTECTED]>:
> On 12/9/05, Francois Beausoleil <[EMAIL PROTECTED]> wrote:
> > Is there a particular reason why this is protected ?
>
> Usually methods are marked as protected when we don't want to make
> them part of the public API.   Every time someone calls our
> 'implementation' methods we either break their applications, or lose
> the option to refactor that code.

I understand that, but is there a way to make something like
#sanitize_sql available for the general public ?  Isn't it a useful
method ?

In my application, I did it another way - I used #count, which ends up
calling count_by_sql.  The nice thing is that #sanitize_sql was
called, so I simply had to provide the parameters in the right format.

In that case, maybe it's not such a useful method...

Anyway, thanks for the heads up !
--
François Beausoleil
http://blog.teksol.info/
___
Rails-core mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-core