~[ Description ]~

Railsex - pronounced “Rails Extensions” OR “Ex Rails” ( easier to say ) - is a plugin for all those cool/good to have/experimental features which cannot possibly be in core due to their nature. As rails itself, this plugin is supposed to be a community effort. So, do chime in !

~[ How to use ]~

Railsex loads extensions only on demand because of the variety of options it provides.

You will need to load the extension in your environment.rb configuration block with following syntax :

config.after_initialize do

config.extenstions = [:respond_to, :lazy_attributes, :console]

end

The plugin requires Rails 2.0.x or higher version.

~[ Current Extensions ]~

- respond_to
- lazy_attributes
- console

~[ Current Features ]~

  • Argument-less support for respond_to :

In your controller you can have :

respond_to do

html
xml  { render :xml => @article }

end

  • Lazy attributes to provide partial updates

You can declare lazy attributes in your model definition :

class Person < ActiveRecord::Base

lazy_attributes :history, :bio

end

In this case, when you do @person.save, ActiveRecord will include bio and history columns in UPDATE query only if you accessed @person.history= or @person.bio= methods.

  • Very common console tricks

    • finders for model so you can do Article, Article

    • “log_to” function to print out db queries to rails irb console

~[ Primary Authors ]~

Pratik Naik - m.onkey.org Unknown people from the internet for “console” extension