Skip to content

Instantly share code, notes, and snippets.

@pacoguzman
Created March 27, 2010 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pacoguzman/345869 to your computer and use it in GitHub Desktop.
Save pacoguzman/345869 to your computer and use it in GitHub Desktop.
Cosillas no vistas anteriormente
* 2010_06_26 - Cosillas Raras de Arel - https://rails.lighthouseapp.com/projects/8994/tickets/4841-multiple-select-only-keep-the-last-one
- Si usas varios select separados se concatenan Post.select("title").select("autor")
- Si usas varios order seaparados se concatenan Post.order("title").order("autor")
- Puedes utilizar reorder para sobreescribier Post.order("title").reorder("autor")
* 2010_06_09 - Al pareacer en i18n si se necesita un string html_safe la clave debe acabar en _html o en .html ActionView::Helpers::TranslationHelper doc
* 2010_04_10 - Fuera del core los helpers que pintan los errores ahora http://github.com/rails/dyanimic_form
* 2010_04_10 - Fuera del core de rails verify (in controllers) ahora http://github.com/rails/verification
* 2010_04_05 - Added all the new HTML5 form types as individual form tag methods (search,
url, number, etc) - http://github.com/rails/rails/commit/f8730e5ce6bba4de7639ac09c6c193458038f748#comments
search_field - search_field_tag
telephone_field - telephone_field_tag
email_field - email_field_tag
* 2010_04_02 - Extending Relations - http://github.com/rails/rails/commit/b77dd218ce845f01753d02fcbc2605c9a5ee93e1
def test_anonymous_extension
relation = Post.where(:author_id => 1).order('id ASC') do
def author
'lifo'
end
end
assert_equal "lifo", relation.author
assert_equal "lifo", relation.limit(1).author
end
def test_named_extension
relation = Post.where(:author_id => 1).order('id ASC').extending(Post::NamedExtension)
assert_equal "lifo", relation.author
assert_equal "lifo", relation.limit(1).author
end
* 2010_03_27 - http://github.com/rails/rails/blob/master/activerecord/lib/active_record/autosave_association.rb
# AutoSaveAssociations
class Post
has_one :author, :autosave => true
end
* 2010_03_27 - http://github.com/rails/rails/commit/faeca694b3d4afebf6b623b493e86731e773c462
# Primary Key now supports limit
create_table :primary_key_limit, :force => true, :id => false do |t|
t.primary_key :id, :limit => 8
end
* 2010_03_27 - http://github.com/rails/rails/commit/3a875e618487a06a56f6cf912cf5440f294921cc
# Changed behavior of touch and added touch! Originally implemented by Obie Fernandez, updated touch! to act as a thin wrapper to touch.
product.touch! # actualiza solo si pasa las validaciones sino lanza una excepción
product.touch # actualiza sin chequear validaciones
* 2010_03_27 - http://github.com/rails/rails/blob/3172db12e4e7f6abab8ddd25f7911d29a5b65ea0/activerecord/lib/active_record/associations.rb
# Associations callbacks
class Project
has_and_belongs_to_many :developers, :after_add => :evaluate_velocity
def evaluate_velocity(developer)
...
end
end
# Possible callbacks are: +before_add+, +after_add+, +before_remove+ and +after_remove+.
# Bi-directional associations
class Dungeon < ActiveRecord::Base
has_many :traps, :inverse_of => :dungeon
has_one :evil_wizard, :inverse_of => :dungeon
end
class Trap < ActiveRecord::Base
belongs_to :dungeon, :inverse_of => :traps
end
class EvilWizard < ActiveRecord::Base
belongs_to :dungeon, :inverse_of => :evil_wizard
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment