<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/atom10full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en-US">
  <title>Web Driven - Blog</title>
  <id>tag:www.webdrivenblog.com,2008:mephisto/</id>
  <generator uri="http://mephistoblog.com" version="0.7.3">Mephisto Noh-Varr</generator>
  
  <link href="http://www.webdrivenblog.com/" rel="alternate" type="text/html" />
  <updated>2008-02-13T14:15:15Z</updated>
  <link rel="self" href="http://feeds.feedburner.com/WebDriven-Blog" type="application/atom+xml" /><entry xml:base="http://www.webdrivenblog.com/">
    <author>
      <name>damien</name>
    </author>
    <id>tag:www.webdrivenblog.com,2008-01-09:21</id>
    <published>2008-01-09T11:13:00Z</published>
    <updated>2008-02-13T14:15:15Z</updated>
    <link href="http://feeds.feedburner.com/~r/WebDriven-Blog/~3/213737335/installing-the-theme-support-plugin-for-rails-2-0" rel="alternate" type="text/html" />
    <title>Installing the Theme support plugin with Rails 2.0</title>
<content type="html">
            &lt;p&gt;I have already written an &lt;a href='http://www.webdrivenblog.com/2007/11/27/installing-the-theme-support-plugin-with-rails-1-2' title='Installing the Theme support plugin with Rails 1.2'&gt;article about the Theme Support Plugin and Rails 1.2&lt;/a&gt;. Now I will talk about using it with &lt;a href='http://weblog.rubyonrails.org/2007/12/7/rails-2-0-it-s-done' title='Rails 2.0: It\'s done!'&gt;Ruby on Rails 2.0&lt;/a&gt;. We consequently need to update the routing system like we did for the Rails 1.2 version. But you will also encounter a problem within the extension of Actionview::Base. Indeed, it will crash when trying to render any template. I have consequently patched the ActionView::Base#render_file.&lt;/p&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;alias_method :theme_support_old_render_file, :render_file

# Overrides the default &lt;tt&gt;Base#render_file&lt;/tt&gt; to allow theme-specific views
def render_file(template_path, use_full_path = true, local_assigns = {})
   search_path = [
      "../themes/#{controller.current_theme}/views",
      "../../themes/#{controller.current_theme}/views",
      "../../themes/#{controller.current_theme}",
      "../../../themes/#{controller.current_theme}/views",
      ".",
      ".."
   ]

   if use_full_path
      search_path.each do |prefix|
         theme_path = prefix +'/'+ template_path
         begin
            template_extension = pick_template_extension(theme_path)

            # Prevent .rhtml (or any other template type) if force_liquid == true
            if force_liquid? and
               template_extension.to_s != 'liquid' and 
               prefix != '.'
               raise ThemeError.new("Template '#{template_path}' must be a liquid document")
            end

            local_assigns['active_theme'] = get_current_theme(local_assigns)

            rendered_template = theme_support_old_render_file(theme_path, use_full_path, local_assigns)
         rescue ActionView::TemplateError =&gt; err
            raise err
         rescue ActionView::ActionViewError =&gt; err
            next
         rescue ThemeError =&gt; err
           raise err
         end
         return rendered_template
      end
      raise ActionViewError, "No #{template_handler_preferences.to_sentence} template found for #{template_path} in #{view_paths.inspect}"
   else
      theme_support_old_render_file(template_path, use_full_path, local_assigns)
   end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In fact the plugin was awaiting an exception during the call to pick_template_extension when the path was not valid. But now Rails 2.0 only raise this exception while trying to render the file. I consequently render the template into a variable which may raise an exception.&lt;/p&gt;

&lt;p&gt;You may apply the patch manually or if you want you can download the full Theme Support plugin for Rails 2.0 using the following links:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href='http://www.webdrivenblog.com/downloads/theme_support/theme_support.tar.bz2' title='Download the Theme support plugin adapted to Rails 2.0 (tar.bz2 archive)'&gt;Theme Support plugin in a tar.bz2 archive&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href='http://www.webdrivenblog.com/downloads/theme_support/theme_support.7z' title='Download the Theme support plugin adapted to Rails 2.0 (7zip archive)'&gt;Theme Support plugin in a 7zip archive&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
          </content>  <feedburner:origLink>http://www.webdrivenblog.com/2008/1/9/installing-the-theme-support-plugin-for-rails-2-0</feedburner:origLink></entry>
  <entry xml:base="http://www.webdrivenblog.com/">
    <author>
      <name>damien</name>
    </author>
    <id>tag:www.webdrivenblog.com,2007-12-06:16</id>
    <published>2007-12-06T15:04:00Z</published>
    <updated>2008-03-03T10:42:59Z</updated>
    <link href="http://feeds.feedburner.com/~r/WebDriven-Blog/~3/196523934/importing-a-csv-file-from-a-form" rel="alternate" type="text/html" />
    <title>Importing a CSV File from a Form</title>
<content type="html">
            &lt;p&gt;This article is a translation of &lt;a href='http://www.spectral-shadow.org/coding-ruby/209/lire-un-fichier-csv-recupere-depuis-un-formulaire' title='Lire un fichier CSV récupéré depuis un formulaire'&gt;the articles I wrote&lt;/a&gt; &lt;a href='http://www.spectral-shadow.org/coding-ruby/210/lire-un-fichier-csv-recupere-depuis-un-formulaire-2eme-partie' title='Lire un fichier CSV récupéré depuis un formulaire, 2ème partie'&gt;on my other blog&lt;/a&gt; during July 2007.&lt;/p&gt;

&lt;p&gt;During my placement at &lt;a href='http://www.dexem.fr' title='Dexem, IVR development using VXML and CCXML'&gt;Dexem&lt;/a&gt; I was mainly developing Voice Publisher: a tool used to create &lt;a href='http://en.wikipedia.org/wiki/Interactive_voice_response' title='Wikipedia: IVR'&gt;Interactive Voice Responses&lt;/a&gt; generated using the &lt;a href='http://en.wikipedia.org/wiki/VoiceXML' title='Wikipedia: VoiceXML'&gt;VoiceXML language&lt;/a&gt;. For this software (developed using &lt;a href='http://www.rubyonrails.org/' title='Official Ruby on Rails website'&gt;Ruby on Rails&lt;/a&gt;), I have to import a CSV file into the database. As it is not very well documented, here is what I did to make it work.&lt;/p&gt;

&lt;p&gt;To recover a file from a form you just need two things: declaring correctly the form, and a field which will permit you to recover the file:&lt;/p&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;&amp;lt;%= start_form_tag({:action =&gt; 'import_csv', :id =&gt; my_object}, :multipart =&gt; true) %&gt;
  &amp;lt;label for="csv_file"&gt;File to Upload&amp;lt;/label&gt;
  &amp;lt;%= file_field_tag "csv_file" %&gt;
&amp;lt;%= end_form_tag %&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then in the action used to import the file:&lt;/p&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;def import_csv
  begin
    CSV::Reader.parse(params[:csv_file]).each do |row|
      unless row[0].nil? or row[1].nil?
        MyObject.create(:name =&gt; row[0], :value =&gt; row[1])
      end
    end
  rescue
    flash[:error] = "There was an error parsing your CSV file"
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In order to check the file is specified when the form is submitted, you may want to add the following code to your action:&lt;/p&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;unless params[:csv][:file] == "" || params[:csv][:file].nil?
  csv_file = params[:csv][:file].read
  unless csv_file == ""
    # read the CSV file from here
    # but this time use csv_file instead of params[:csv][:file]
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The first test...&lt;/p&gt;
&lt;pre&gt;&lt;code class='ruby'&gt;unless params[:csv][:file] == "" || params[:csv][:file].nil?&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;...will check a file is specified for Firefox and Internet Explorer. The second test...&lt;/p&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;unless csv_file == ""&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;...is for Opera. If no file is given, Opera will still give us a StringIO object, which when read will give an empty string. On the contrary, Firefox and Internet Explorer will not give a StringIO if no file is specified, instead they will give an empty string.&lt;/p&gt;

&lt;p&gt;That's it ! Now you know how to read a csv file from a form using &lt;a href='http://www.rubyonrails.org' title='Official Ruby on Rails site'&gt;Ruby on Rails&lt;/a&gt;. You may want to have a look at the &lt;a href='http://rubyforge.org/projects/fastercsv/' title='Faster and smaller library than Ruby Standard CSV Library'&gt;fastercsv library&lt;/a&gt; which will provide, as the name says, faster reading of your csv files :)&lt;/p&gt;
          </content>  <feedburner:origLink>http://www.webdrivenblog.com/2007/12/6/importing-a-csv-file-from-a-form</feedburner:origLink></entry>
  <entry xml:base="http://www.webdrivenblog.com/">
    <author>
      <name>damien</name>
    </author>
    <id>tag:www.webdrivenblog.com,2007-12-06:13</id>
    <published>2007-12-06T10:43:00Z</published>
    <updated>2008-02-13T14:15:33Z</updated>
    <link href="http://feeds.feedburner.com/~r/WebDriven-Blog/~3/196034760/a-simple-users-system-2-2" rel="alternate" type="text/html" />
    <title>A simple users system 2/2</title>
<content type="html">
            &lt;p&gt;Now that we have a user model and now that Access Control System is updated according to it, we can use it correctly in our controllers and view as usual. If you administrate a part of your application using Active Scaffold, you may edit your controllers as follows:&lt;/p&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;class CustomerAccountsController &amp;lt; ActionController
  active_scaffold
end&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;class CustomersController &amp;lt; ActionController
  access_control :DEFAULT =&gt; “admin | reseller”,
                 [:create, :update, :destroy] =&gt; “reseller”

  active_scaffold :customers do |config|
    config.columns = [:login, :email, :first_name, :last_name, :password, :password_confirmation, :customer_account]
    list.columns.exclude :password, :password_confirmation
  end


  def authorize_create?
    permit?(“reseller”)
  end
  def authorize_update?
    permit?(“reseller”)
  end
  def authorize_delete?
    permit?(“reseller”)
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The authorize methods are used by Active Scaffold in views: the links to create, update or delete are not shown when these methods return false. That's it !&lt;/p&gt;
          </content>  <feedburner:origLink>http://www.webdrivenblog.com/2007/12/6/a-simple-users-system-2-2</feedburner:origLink></entry>
  <entry xml:base="http://www.webdrivenblog.com/">
    <author>
      <name>damien</name>
    </author>
    <id>tag:www.webdrivenblog.com,2007-11-27:12</id>
    <published>2007-11-27T13:58:00Z</published>
    <updated>2008-02-13T14:16:11Z</updated>
    <link href="http://feeds.feedburner.com/~r/WebDriven-Blog/~3/195039042/installing-the-theme-support-plugin-with-rails-1-2" rel="alternate" type="text/html" />
    <title>Installing the Theme support plugin with Rails 1.2</title>
<content type="html">
            You may have wanted to install the &lt;a href='http://www.mattmccray.com/pivot/archive.php?c=Theme_Support' title='Matt McCray\'s blog with Theme Support Plugin'&gt;Theme support plugin&lt;/a&gt; in your &lt;a href='http://www.rubyonrails.org' title='Ruby on Rails\' official site'&gt;Ruby on Rails&lt;/a&gt; application. If you are using Rails 1.1, you won't have any problem, but the plugin as not been updated since Rails 1.2 is out. If you follow these steps it will work nicely:

&lt;p&gt;As usual, install from the subversion repository: 
&lt;pre&gt;&lt;code&gt;./script/plugin install http://mattmccray.com/svn/rails/plugins/theme_support&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;Then update the file which overrides your application's routes. It should be in /vendor/plugins/theme_support/lib/patches/routeset_ex.rb, replace its content with:
&lt;pre&gt;&lt;code class='ruby'&gt;# Extends ActionController::Routing::RouteSet to automatically add the theme routes
class ActionController::Routing::RouteSet
  alias_method :__draw, :draw

  # Overrides the default RouteSet#draw to automatically
  # include the routes needed by the ThemeController
  def draw
    clear!
    map = Mapper.new(self)

    create_theme_routes(map)
    yield map

    named_routes.install
  end

  # Creates the required routes for the ThemeController...
  def create_theme_routes(map)
    map.theme_images "/themes/:theme/images/*filename", :controller =&gt; 'theme', :action =&gt; 'images'
    map.theme_stylesheets "/themes/:theme/stylesheets/*filename", :controller =&gt; 'theme', :action =&gt; 'stylesheets'
    map.theme_javascript "/themes/:theme/javascript/*filename", :controller =&gt; 'theme', :action =&gt; 'javascript'
    map.connect "/themes/*whatever", :controller =&gt; 'theme', :action =&gt; 'error'
  end

end&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;Then generate a theme using:
&lt;pre&gt;&lt;code&gt;./script/generate theme my_theme&lt;/code&gt;&lt;/pre&gt;
You should at that point be able to get for example the following URL: &lt;code&gt;http://localhost:3000/themes/my_theme/images/preview.png&lt;/code&gt; Your logs should say that the &lt;code&gt;images&lt;/code&gt; action of the &lt;code&gt;themes&lt;/code&gt; controller has been used to send the image file.&lt;/p&gt;

&lt;p&gt;If that's the case, your installation is successful ! If it is not the case, do not hesitate to leave a comment here and we'll try to see what is the problem.&lt;/p&gt;
          </content>  <feedburner:origLink>http://www.webdrivenblog.com/2007/11/27/installing-the-theme-support-plugin-with-rails-1-2</feedburner:origLink></entry>
  <entry xml:base="http://www.webdrivenblog.com/">
    <author>
      <name>damien</name>
    </author>
    <id>tag:www.webdrivenblog.com,2007-11-25:11</id>
    <published>2007-11-25T17:09:00Z</published>
    <updated>2008-02-13T14:16:20Z</updated>
    <link href="http://feeds.feedburner.com/~r/WebDriven-Blog/~3/195039043/a-simple-users-system-part-1" rel="alternate" type="text/html" />
    <title>A simple users system 1/2</title>
<content type="html">
            &lt;p&gt;At &lt;a href='http://www.dexem.com/' title='Dexem, Voice Applications using VoiceXML, CCXML...'&gt;Dexem&lt;/a&gt; we are currently working on a new application in which we have to take into account several different users with different permissions. For example we have an admin, several resellers and several customers.&lt;/p&gt;

&lt;p&gt;To put that in place, we are gonna use:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href='http://technoweenie.stikipad.com/plugins/show/Acts+as+Authenticated' title='Acts as Authenticated: An authentication plugin for Ruby on Rails'&gt;Acts as authenticated&lt;/a&gt; to create the users model and the authentication controller.&lt;/li&gt;
&lt;li&gt;&lt;a href='http://agilewebdevelopment.com/plugins/acl_system' title='Acl System: Access Control Plugin for Ruby on Rails'&gt;Acl System&lt;/a&gt; to control access to controllers and actions.&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.activescaffold.com' title='ActiveScaffold: A Ruby on Rails plugin for dynamic, AJAX CRUD interfaces'&gt;Active Scaffold&lt;/a&gt; to create easily an interface to manage those users.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The default behavior of &lt;a href='http://agilewebdevelopment.com/plugins/acl_system' title='Acl System: Access Control Plugin for Ruby on Rails'&gt;Acl System&lt;/a&gt; is to look for a &lt;code&gt;roles&lt;/code&gt; relation in the &lt;code&gt;User&lt;/code&gt; model. In the other applications we have at &lt;a href='http://www.dexem.com/' title='Dexem, Voice Applications using VoiceXML, CCXML...'&gt;Dexem&lt;/a&gt;, a user may have several roles and each role defines access to specific objects of the application.&lt;/p&gt;

&lt;p&gt;But for this application, the permission system should be much simpler. That’s why I decided a user should only have one role which will subsequently define a set of permissions. So instead of having a &lt;code&gt;User&lt;/code&gt; model plus a &lt;code&gt;Role&lt;/code&gt; model and having links between them, I simplified the system to implement inheritance of the &lt;code&gt;User&lt;/code&gt; class for each type of user.&lt;/p&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;class CreateUsers &amp;lt; ActiveRecord::Migration
  def self.up
    create_table "users", :force =&gt; true do |t|
      # acts_as_authenticated attributes
      t.column :login,                     :string
      t.column :email,                     :string
      t.column :crypted_password,          :string, :limit =&gt; 40
      t.column :salt,                      :string, :limit =&gt; 40
      t.column :created_at,                :datetime
      t.column :updated_at,                :datetime
      t.column :remember_token,            :string
      t.column :remember_token_expires_at, :datetime

      # common attributes
      t.column :first_name, :string
      t.column :last_name, :string
      t.column :type, :string
      
      # reseller attributes
      t.column :reseller_account_id, :integer

      # customer attributes
      t.column :customer_account_id, :integer
    end
  end

  def self.down
    drop_table "users"
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In the &lt;code&gt;User&lt;/code&gt; class defined by &lt;a href='http://technoweenie.stikipad.com/plugins/show/Acts+as+Authenticated' title='Acts as Authenticated: An authentication plugin for Ruby on Rails'&gt;Acts as authenticated&lt;/a&gt; we add a &lt;code&gt;role&lt;/code&gt; method:&lt;/p&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;def role
  self.class.to_s.underscore
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and in &lt;a href='http://agilewebdevelopment.com/plugins/acl_system' title='Acl System: Access Control Plugin for Ruby on Rails'&gt;Acl System&lt;/a&gt; we modify the role checking method:&lt;/p&gt;



&lt;pre&gt;&lt;code class='ruby'&gt;module Caboose
  class RoleHandler &amp;lt; AccessHandler
    def check(key, context)
      context[:user].role == key.downcase
    end
  end
end&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The users classes:&lt;/p&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;class Admin &amp;lt; User
end
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;class Reseller &amp;lt; User
  belongs_to :reseller_account
end
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;class Customer &amp;lt; User
  belongs_to :customer_account
end&lt;/code&gt;&lt;/pre&gt;

With that code you have everything you need to make use of a basic users system. In the next part , I will explain and show how easy it is to integrate it with the use of &lt;a href='http://www.activescaffold.com' title='ActiveScaffold: A Ruby on Rails plugin for dynamic, AJAX CRUD interfaces'&gt;Active Scaffold&lt;/a&gt;.

Obviously, any comments on the design and ways to improve it are welcome :)
          </content>  <feedburner:origLink>http://www.webdrivenblog.com/2007/11/25/a-simple-users-system-part-1</feedburner:origLink></entry>
  <entry xml:base="http://www.webdrivenblog.com/">
    <author>
      <name>damien</name>
    </author>
    <id>tag:www.webdrivenblog.com,2007-10-28:6</id>
    <published>2007-10-28T17:45:00Z</published>
    <updated>2008-02-13T14:16:27Z</updated>
    <link href="http://feeds.feedburner.com/~r/WebDriven-Blog/~3/195039044/assigning-a-collection-to-has_many-through" rel="alternate" type="text/html" />
    <title>Assigning a collection to has_many :through</title>
<content type="html">
            &lt;p&gt;This first article about &lt;a href='http://www.rubyonrails.org/' title='Official Ruby on Rails website'&gt;Ruby on Rails&lt;/a&gt; is quite technical, it explains how to handle assignment of collections to a &lt;code&gt;has_many :through&lt;/code&gt; relationship, as it is not the easiest kind of relationship to handle in Rails. I have used some &lt;a href='#references' title='Scroll down to references'&gt;references&lt;/a&gt; and made some improvements to the code so that it suits best my needs, but it may not be what you want, don't hesitate to post a comment to suggest some improvements or to ask for more :)&lt;/p&gt;

&lt;p&gt;As &lt;code&gt;has_many :through&lt;/code&gt; relationship is not handled using proxy collections like &lt;code&gt;has_and_belongs_to_many&lt;/code&gt; relationships, we need to be a little tricky to make collection assignments. If you google a little to find a solution, you may find &lt;a href='http://www.ruby-forum.com/topic/76825' title='Ruby on Rails &gt; Collection assignment to a has_many :through'&gt;this subject on Ruby-Forum&lt;/a&gt;. This solution works well, but it will automatically save your data into the database. If like me you’re an “&lt;code&gt;update_attributes&lt;/code&gt; addict”, you would like the affectation not to write into the database until the model is validated. So here is how I handle this assignment...&lt;/p&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;class Account &amp;lt; ActiveRecord::Base
  has_many :memberships, :dependent =&gt; :destroy
  has_many :users, :through =&gt; :memberships

  attr_reader :old_users
  after_save :save_users

  # “Reminds” the old users used
  # and replaces them by the new ones
  def users=(users)
    @old_users = Array.new
    self.users.each { |user| @old_users &amp;lt;&amp;lt; user }

    self.users.clear
    users.each { |user| self.users &amp;lt;&amp;lt; user }
  end

  private
  def save_users
    Membership.set_users_for_account self, self.users
    memberships.reset
    users.reset
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;class Users &amp;lt; ActiveRecord::Base
  has_many :memberships, :dependent =&gt; :destroy
  has_many :accounts, :through =&gt; :memberships
end
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class='ruby'&gt;class Membership &amp;lt; ActiveRecord::Base
  belongs_to :account
  belongs_to :user

  def Membership.set_users_for_account(account, users)
    old_users = account.old_users
    
    # at account creation we would add the users twice otherwise
    unless old_users.nil?
      delete_from account,  (old_users - users)
      add_to      account,  (users - old_users)
    end
  end
  
  private
  def Membership.delete_from(account, users)
    unless users.empty?
      delete_all ['account_id = ? and user_id in (?)',
                   account.id, users.collect { |u| u.id }]
    end
  end
  
  def Membership.add_to(account, users)
    unless users.empty?
      self.transaction do
        users.each do | user|
          create! :account =&gt; account, :user =&gt; user
        end
      end
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This way, when you will make an &lt;code&gt;update_attributes&lt;/code&gt; to your account giving a collection of users in parameters (and other account attributes eventually), the list of users associated to the account won’t be updated if the model is not valid.&lt;/p&gt;

&lt;p&gt;I’m not the best Ruby on Rails programmer in the world, I would be glad to see your comments on how I could improve this code or even on how I could improve the way I handle collections assignment with &lt;code&gt;has_many :through&lt;/code&gt; relationships.&lt;/p&gt;

&lt;p&gt; This Article was written using Rails 1.1.6, this way of handling has_many :through relationship doesn't work with Rails 2.0 at creation of object&lt;/p&gt;

&lt;h3&gt;&lt;a class='anchor'&gt;References&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href='http://blog.hasmanythrough.com/2006/4/20/many-to-many-dance-off' title='Josh Susser\'s comparison of has_many :through and has_and_belongs_to_many relationships'&gt;Many-to-many Dance-off!&lt;/a&gt; by Josh Susser&lt;/li&gt;
  &lt;li&gt;&lt;a href='http://blog.hasmanythrough.com/2006/4/17/join-models-not-proxy-collections' title='Josh Susser\'s explanation on has_many :through relationship'&gt;Why aren't join models proxy collections?&lt;/a&gt; by Josh Susser&lt;/li&gt;
  &lt;li&gt;&lt;a href='http://www.ruby-forum.com/topic/76825' title='Post on how to handle collection assignments with has_many :through'&gt;Collection assignment to a has_many :through&lt;/a&gt; on Ruby-Forum&lt;/li&gt;
&lt;/ul&gt;
          </content>  <feedburner:origLink>http://www.webdrivenblog.com/2007/10/28/assigning-a-collection-to-has_many-through</feedburner:origLink></entry>
  <entry xml:base="http://www.webdrivenblog.com/">
    <author>
      <name>damien</name>
    </author>
    <id>tag:www.webdrivenblog.com,2007-10-23:4</id>
    <published>2007-10-23T20:10:00Z</published>
    <updated>2007-10-28T17:57:37Z</updated>
    <link href="http://feeds.feedburner.com/~r/WebDriven-Blog/~3/195039057/is-it-2-0" rel="alternate" type="text/html" />
    <title>Is it 2.0 ?</title>
<content type="html">
            &lt;p&gt;Some of my friends had the good idea to wonder “what is 2.0 ?”. And as curious as it seems to be, they don’t try to answer like most web developers would say: Ajax + Users driven content… they simply ask &lt;span class='caps'&gt;YOU&lt;/span&gt;: “is it 2.0 ?”&lt;/p&gt;


	&lt;p&gt;Find out more by visiting their &lt;a href='http://www.isit20.com' title='Is it 2.0 ?'&gt;very 2.0 website&lt;/a&gt; :)&lt;/p&gt;
          </content>  <feedburner:origLink>http://www.webdrivenblog.com/2007/10/23/is-it-2-0</feedburner:origLink></entry>
  <entry xml:base="http://www.webdrivenblog.com/">
    <author>
      <name>damien</name>
    </author>
    <id>tag:www.webdrivenblog.com,2007-10-22:1</id>
    <published>2007-10-22T18:38:00Z</published>
    <updated>2007-10-28T17:57:49Z</updated>
    <link href="http://feeds.feedburner.com/~r/WebDriven-Blog/~3/195039058/welcome-to-web-driven" rel="alternate" type="text/html" />
    <title>Welcome to Web Driven</title>
<content type="html">
            &lt;p&gt;Finally I did it !
Here is my new blog. As you can see it is powered by &lt;a href='http://www.mephistoblog.com/' title='Mephisto, publish with impunity'&gt;Mephisto&lt;/a&gt; using the &lt;a href='http://www.rubyonrails.org/'&gt;Ruby on Rails&lt;/a&gt; framework. I chose to host this blog on &lt;a href='http://www.hostingrails.com/' title='Hosting Rails, Ruby on Rails web host'&gt;HostingRails.com&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Well, as the title says, this blog is about web development. I will try to talk about many different things: mostly including &lt;a href='http://www.ruby-lang.org/'&gt;Ruby&lt;/a&gt; and &lt;a href='http://www.rubyonrails.org/'&gt;Ruby on Rails&lt;/a&gt; development, using &lt;a href='http://www.prototypejs.org/' title='Prototype JavaScript framework'&gt;Prototype&lt;/a&gt; and &lt;a href='http://script.aculo.us/' title='Script.aculo.us Javacript framework'&gt;Script.aculo.us&lt;/a&gt; with Rails to improve user experience… and all the various things I may find interesting to talk about.&lt;/p&gt;


	&lt;p&gt;You may realize my english is not that good, but I’ll do my best to improve and make my writings pleasant to read :)&lt;/p&gt;
          </content>  <feedburner:origLink>http://www.webdrivenblog.com/2007/10/22/welcome-to-web-driven</feedburner:origLink></entry>
</feed>
