Posts for: #Ruby on Rails

Ruby on Rails 2.0: Released

As I previously announced Ruby on Rails 2.0 was released.

What’s new?

Active Record

  • Performances
  • Sexy Migrations
  • Foxy Fixtures
  • XML Deserialization
  • JSON Serialization
  • acts_as Plugins Removal From Core
  • Database Adapters Gems
  • with_scope Protection

Action Pack

  • Resources
  • REST Improvements
  • Multiview
  • Record Identification
  • HTTP Loving
  • Security Improvements
  • Exception Handling
  • Cookie Store Sessions
  • New Request Profiler
  • AtomFeedHelper

Active Resource

  • Official Inclusion In Core
  • Remote CRUD

Action Mailer

[]

Acts As Resource: Combining ActiveRecord and ActiveResource

Would you use both ActiveRecord and ActiveResource in one class? Now with Acts As Resource you can!!

Example

class Carrot acts_as_resource self.site = 'http://localhost:3000'
belongs_to :bunny

validates_presence_of :color
validates_uniqueness_of :color
validates_length_of :color, :within => 2..23,
                    :if => lambda { |c| c.color && !c.color.empty? }
validates_format_of :color,
                    :with => /[\w\s]+$/,
                    :if => lambda { |c| c.color && !c.color.empty? }

before_create :please_call_me_before_create
def self.validate
  logger.debug("VALIDATE #{color}")
end

def please_call_me_before_create
  logger.debug("Ohhh, so you called me..")
end

end

[]

Rails: How To Modify Template Contents Before Rendering

Just a quick snippet to modify template contents before ActionView render them via ERB.

ActionView::Base.class_eval do alias_method :action_view_render_template, :render_template def render_template(template_extension, template, file_path = nil, local_assigns = {}) template ||= read_template_file(file_path, template_extension) template = "
#{template}
" # add your contents here. action_view_render_template(template_extension, template, file_path, local_assigns) end end

You can add this code to environment.rb, but is preferible a plugin.

[]

Rails To Italy 07 Updates

Rails To Italy 07 conference has just started, stay tuned.

UPDATE: 10:38

Sorry, network problems Zed Shaw, has finished his keynote.

James Cox now is talking about Rails scalability

UPDATE: 14:37

Waiting for Thomas Fuchs!!

Sorry, but in the past two days we have had a lot of network problems.

[]