Updating / validating mass update rails association My recipes model is as follows

has_many :quantities
has_many :ingredients, :through =&gt; :quantities, :uniq =&gt; true
has_many :sizes, :through =&gt; :quantities, :uniq =&gt; true


And the controller action im trying to refactor

class Admin::QuantitiesController &lt; Admin::AdminController
  layout 'admin'

  authorize_resource :class =&gt; :controller

  def create
    recipe        = Recipe.find(params[:recipe_id])
    values      = params[:quantity][:ingredient]
    @quantities = Quantity.find(values.keys)

    @quantities_errors = {}
    @quantities.each do |quantity|
        if quantity.value != values[quantity.id.to_s]
            quantity.value = values[quantity.id.to_s]
            if quantity.valid?
                quantity.save
            else
                @quantities_errors[quantity.id] = quantity.errors.messages
            end
        end
    end

    unless @quantities_errors
        redirect_to edit_admin_recipe_path(recipe), notice: 'Ingredients was successfully added.'
    else
        redirect_to edit_admin_recipe_path(recipe), alert: @quantities_errors
    end

  end

end
Some notes:


This is a edit_admin_recipe form, so you should POST to Admin::RecipesController#update. 
Use Rails infrastructure for the models (accepts_nested_attributes_for) to save nested data. Controllers must be kept simple and clean.