Ruby on Rails 2.0 will be released in the next hours!!
Posts for: #Rails
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.
Rails To Italy 07 - Q&A Session with DHH
Rails To Italy 07 will have a Q&A session with David Heinemeier Hansson, the creator of Ruby on Rails.
If you want to ask something to him, just send a mail to program@railstoitaly.org, the organization will select the questions.