[Rails-core] [PATCH] ActionDispatch MemCacheStore violates encapsulation principle

2010-06-12 Thread Luca Guidi
When pass :cache param to ActionDispatch::Session::MemCacheStore, it should be removed from options, otherwise it remains "published". This violates the OOP encapsulation principle. I created a LH ticket with a patch http://bit.ly/cGDaWs Luca -- lucaguidi.com twitter.com/jodosha -- You receive

[Rails-core] Re: Reasoning for not supporting ruby 1.8.6 in Rails 3.0

2009-09-09 Thread Luca Guidi
You can safely use Passenger with Ruby 1.9.1, avoiding REE. - Luca -- lucaguidi.com twitter.com/jodosha --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email

[Rails-core] Re: Reasoning for not supporting ruby 1.8.6 in Rails 3.0

2009-09-09 Thread Luca Guidi
The EY team will maintain 1.8.x branch only for security issues, I don't think they will backport all the 1.9.x features. Because it's a non-sense. The present (not the future) of Ruby it's 1.9.1, honestly don't know why the majority (myself included) is still on the old-and-beloved 1.8.6. The "Bi

[Rails-core] Re: I18n support for plugins/gems?

2009-08-26 Thread Luca Guidi
Agree with Francesc -- lucaguidi.com twitter.com/jodosha --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscr

[Rails-core] Re: Making Active Resource act like Active Record...

2009-08-10 Thread Luca Guidi
I don't know if this may help, but a couple of years ago I wrote a plugin in order to unify AR and ARes behaviors in one class: http://github.com/jodosha/acts-as-resource/tree/master class Carrot acts_as_resource self.site = "http://api.example.com"; belongs_to :bunny valdates_presence_of

[Rails-core] Re: ActiveSupport: alternative Block execution on empty Enumerable

2009-08-06 Thread Luca Guidi
Just updated the benchmark (http://gist.github.com/163274), tried to solve the issue using #any? instead of #try, but isn't fast for filled arrays: module Enumerable def else not any? ? yield : self # don't try this at home end end Luca -- lucaguidi.com twitter.com/jodosha --~--~

[Rails-core] Re: ActiveSupport: alternative Block execution on empty Enumerable

2009-08-06 Thread Luca Guidi
What about using Object#try and avoiding the explicit &block argument?This avoid to instantiate a Proc object *for each* method execution, if any block isn't passed and the enumerable is empty the VM will raise a LocalJumpError. module Enumerable def else self.try(:empty?) ? yield : self e

[Rails-core] [PATCH] Bytes calculation speed up for ActiveSupport

2009-06-13 Thread Luca Guidi
The current bytes calculation is inefficient, because every time it instantiate a Fixnum (1024) and generates a lot of method calls. Example: if I call 16.gigabytes it internally invokes megabyte and kilobyte, instantiating three times 1024. The number of internal calls and Fixnum instantiatio

[Rails-core] Re: Lighthouse query for what's remaining in 2.3.3?

2009-06-06 Thread Luca Guidi
Hi, May I suggest this one? http://rails.lighthouseapp.com/projects/8994/tickets/2251 Please look at the bottom of the comments list, my patch has spotlighted another bug, but the resolution is controversy, due to opposite behaviors allowed to the hmt association. I found a TODO in the concer

[Rails-core] Re: Deleting records using nested attributes decreases the counter cache twice

2009-06-05 Thread Luca Guidi
Hi, just gave a look at your code, the problem is trivial: you shouldn't call both #update_attributes *and* #save, because they performs the same operation. The former is a syntax shortcut: person.name = "luca" person.age = 26 person.save # or person.update_attributes :name => "luca", :age =>

[Rails-core] Re: Deleting records using nested attributes decreases the counter cache twice

2009-06-03 Thread Luca Guidi
Hi, please can you specify which version of Rails are you currently using, and an example of the code that causes your problem? I tried to reproduce it with: compra.update_attributes :detalle_de_compras_attributes => [{:id => 953125641, :_delete => true}] but works fine for me, it decrements t

[Rails-core] Re: redesigning mass attribute assignment (activerecord 3.0?)

2009-06-02 Thread Luca Guidi
Hi Ryan, glad you like my proposal. I implemented all the changes mentioned in my last email, only #assign_attributes is pending. http://bit.ly/1wSmS Few considerations: * I implemented #protect_from_mass_assignment at class level, instead of a top-level ActiveRecord flag, because gives a fine

[Rails-core] Re: redesigning mass attribute assignment (activerecord 3.0?)

2009-06-01 Thread Luca Guidi
Assumptions: - attr_accessible/attr_protected aren't used because coders often forget about those macros, and also because they are annoying to work with. The current API doesn't encourage them. - attr_protected is dangerous (rails-spikes.com) - Protection should be at class level - Controllers sh

[Rails-core] Re: ActiveResource connection.post custom headers

2009-05-29 Thread Luca Guidi
Hi Ben, I guess you are going to create an order on the remote service, why don't you use ActiveResource in the following way? class Order < ActiveResource::Base self.site = "http://api.example.com"; headers["X-TheRequiredApplicationKey"] = "ThisIsAReallyGreatApplicationKey" headers["

[Rails-core] [PATCH] SqlBypass session store doesn't use ActiveRecord::Base connection

2009-03-31 Thread Luca Guidi
All the methods in ActiveRecord::SessionStore::SqlBypass use @@connection class var, instead of the homonym class method. This of course doesn't not guarantee that var isn't nil. Try it by yourself: # config/initializers/session_store.rb ActionController::Base.session_store = :active_record_store

[Rails-core] [PATCH] Nested attributes doesn't run removing association callbacks

2009-03-05 Thread Luca Guidi
class Person < ActiveRecord::Base has_many :emails, :after_remove => :set_preferred_email accepts_nested_attributes_for :emails, :allow_destroy => true private def set_preferred_email # ... end end person.emails.delete(email) # => it run the callback person.update_att

[Rails-core] [PATCH] Rake tasks for run engine migrations

2009-02-24 Thread Luca Guidi
This patch adds two tasks: * db:migrate:engines * db:migrate:engines:down The first one allows to run all the migrations stored in the db/migrate directory of each plugin. It runs migrations in the same order Rails::Initializer register the plugins, this means if you force an order by env

[Rails-core] XmlMini autoload cause endless loop with Ruby 1.9.1

2009-01-29 Thread Luca Guidi
I'm using Ruby 1.9.1-rc2 (ruby 1.9.1p0 (2009-01-20 revision 21700) [i386-darwin9.5.0]) and trying to run unit tests for AS. I noticed an endless loop for all the cases which are using XmlMini, which is autoloaded: autoload :XmlMini, 'active_support/xml_mini' Autoload expect to find ActiveSupport

[Rails-core] Rails.cache.write returns false with MemCacheStore

2008-10-20 Thread Luca Guidi
Rails.cache.write returns false with MemCacheStore even if the operation was successful done. result = Rails.cache.write('key', 'value') Rails.cache.read('key') # => value puts result # => false The problem is trivial: MemCache#set doesn't return any result, so the check performed by MemCacheSto

[Rails-core] Memcached uses local time instead of configured time zone

2008-08-25 Thread Luca Guidi
Hi all, I noticed a strange behavior with Memcached store. The first time I store an model object, Memcached correctly store the timestamps, using the configured time zone (UTC for me). When I update that object and cache it again, Memcached uses the server local time for the updated_at attribute

[Rails-core] Eager loading doesn't respect :limit option of the macro association

2008-06-28 Thread Luca Guidi
Hi all, I found a strange behaviour in eager loading: class Category < ActiveRecord::Base has_and_belongs_to_many :movies has_and_belongs_to_many :most_recent_movies, :class_name => 'Movie', :order => 'created_at DESC', :limit => 10 end class Movie < ActiveRecord::Base has_and_belongs_

[Rails-core] Re: camelize

2008-06-04 Thread Luca Guidi
Hi Lawrence, I experienced the same issue, of course camelize doesn't work properly, but just add the following two lines to the plugin init.rb I can run Rails: require File.dirname(__FILE__) + '/lib/authorization' require File.dirname(__FILE__) + '/lib/authorization/stateful_roles' I didn't i

[Rails-core] Re: Internationalization/Localization of Rails (update)

2008-01-04 Thread Luca Guidi
I have developed an high level extension for Globalize, for inplace translations of views, via ajax. You can find a guide, tips, video tutorials and more, at the related page: http://www.lucaguidi.com/pages/click-to-globalize I hope this is useful for your purposes. Luca. -- blog: www.lucagui

[Rails-core] Re: Broken 2.0.2 gems

2007-12-18 Thread Luca Guidi
Josh Susser wrote: > In the meantime, this seems to work: > > gem install rails --source http://gems.rubyonrails.org Notice the missing platform. $ sudo gem update rails --source http://gems.rubyonrails.org Password: Updating installed gems... Attempting remote update of rails Select which ge