David Heinemeier Hansson
2004-Dec-23 00:46 UTC
[ANN] Rails 0.9.2: End of requiring models, models in sessions, fixes
Thanks to the powers of const_missing, you no longer need to explicitly require models that reside in their own files. They’ll spring to life automatically, which is very helpful for inheritance where you’re documenting the dependency using subclassing already and for instant use of models in script/console. It’s now also safe to place models in sessions without worrying about stale association caches—they’re cleared at the end of each request. In addition, there are about 33 other fixes, changes, and features in this release. Update your Rails through gems with "gem install rails" Rails 0.9.2 ========== * Fixed CTRL-C exists from the Breakpointer to be a clean affair without error dumping [Kent Sibilev] * Fixed "rake stats" to work with sub-directories in models and controllers and to report the code to test ration [Scott Baron] * Added that Active Record associations are now reloaded instead of cleared to work with the new const_missing hook in Active Record. * Added graceful handling of an inaccessible log file by redirecting output to STDERR with a warning #330 [rainmkr] * Added support for a -h/--help parameter in the generator #331 [Ulysses] * Fixed that File.expand_path in config/environment.rb would fail when dealing with symlinked public directories [mjobin] * Upgraded to Action Pack 1.1.0 and Active Record 1.3.0 Active Record 1.3.0 ================== * Added a require_association hook on const_missing that makes it possible to use any model class without requiring it first. This makes STI look like: before: require_association ''person'' class Employee < Person end after: class Employee < Person end This also reduces the usefulness of Controller.model in Action Pack to currently only being for documentation purposes. * Added that Base.update_all and Base.delete_all return an integer of the number of affected rows #341 * Added scope option to validation_uniqueness #349 [Kent Sibilev] * Added respondence to *_before_type_cast for all attributes to return their string-state before they were type casted by the column type. This is helpful for getting "100,000" back on a integer-based validation where the value would normally be "100". * Added allow_nil options to validates_inclusion_of so that validation is only triggered if the attribute is not nil [what-a-day] * Added work-around for PostgreSQL and the problem of getting fixtures to be created from id 1 on each test case. This only works for auto-incrementing primary keys called "id" for now #359 [Scott Baron] * Added Base#clear_association_cache to empty all the cached associations #347 [Tobias Luetke] * Added more informative exceptions in establish_connection #356 [bitsweat] * Added Base#update_attributes that''ll accept a hash of attributes and save the record (returning true if it passed validation, false otherwise). Before: person.attributes = @params["person"] person.save Now: person.update_attributes(@params["person"]) * Added Base.destroy and Base.delete to remove records without holding a reference to them first. * Added that query benchmarking will only happen if its going to be logged anyway #344 * Added higher_item and lower_item as public methods for acts_as_list #342 [Tobias Luetke] * Fixed that options[:counter_sql] was overwritten with interpolated sql rather than original sql #355 [bitsweat] * Fixed that overriding an attribute''s accessor would be disregarded by add_on_empty and add_on_boundary_breaking because they simply used the attributes[] hash instead of checking for @base.respond_to?(attr.to_s). [Marten] * Fixed that Base.table_name would expect a parameter when used in has_and_belongs_to_many joins [Anna Lissa Cruz] * Fixed that nested transactions now work by letting the outer most transaction have the responsibilty of starting and rolling back the transaction. If any of the inner transactions swallow the exception raised, though, the transaction will not be rolled back. So always let the transaction bubble up even when you''ve dealt with local issues. Closes #231 and #340. * Fixed validates_{confirmation,acceptance}_of to only happen when the virtual attributes are not nil #348 [dpiddy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] * Changed the interface on AbstractAdapter to require that adapters return the number of affected rows on delete and update operations. * Fixed the automated timestamping feature when running under Rails'' development environment that resets the inheritable attributes on each request. Action Pack 1.1.0 ================ * Added search through session to clear out association caches at the end of each request. This makes it possible to place Active Record objects in the session without worrying about stale data in the associations (the main object is still subject to caching, naturally) #347 [Tobias Luetke] * Added more informative exception when using helper :some_helper and the helper requires another file that fails, you''ll get an error message tells you what file actually failed to load, rather than falling back on assuming it was the helper file itself #346 [dblack] * Added use of *_before_type_cast for all input and text fields. This is helpful for getting "100,000" back on a integer-based validation where the value would normally be "100". * Added Request#port_string to get something like ":8080" back on 8080 and "" on 80 (or 443 with https). * Added Request#domain (returns string) and Request#subdomains (returns array). * Added POST support for the breakpoint retries, so form processing that raises an exception can be retried with the original request [Florian Gross] * Fixed regression with Base#reset_session that wouldn''t use the the DEFAULT_SESSION_OPTIONS [adam-3MoI1BKEnF/JuAXsgwRMTA@public.gmane.org] * Fixed error rendering of rxml documents to not just swallow the exception and return 0 (still not guessing the right line, but hey) * Fixed that textilize and markdown would instantiate their engines even on empty strings. This also fixes #333 [Ulysses] * Fixed UrlHelper#link_to_unless so it doesn''t care if the id is a string or fixnum [zenspider]
> I think "rake stats" should also include the views files, don''t you > think? They have to be written and maintained the same way as > controllers and models do.Yeah, would be nice to have that in too. I don''t consider it code in the same sense as helpers, controllers, and models. If you do have something qualifying as code, you should abstract it to a helper ;) -- David Heinemeier Hansson, http://www.basecamphq.com/ -- Web-based Project Management http://www.rubyonrails.org/ -- Web-application framework for Ruby http://macromates.com/ -- TextMate: Code and markup editor (OS X) http://www.loudthinking.com/ -- Broadcasting Brain
Guys, I think "rake stats" should also include the views files, don''t you think? They have to be written and maintained the same way as controllers and models do. rgds, Demetrius David Heinemeier Hansson wrote:> > Rails 0.9.2 > ==========> > > * Fixed "rake stats" to work with sub-directories in models and > controllers and to report the code to test ration [Scott Baron] >