[Rails] Ignoring Validations In An Admin Tool?
Craig White
craigwhite at azapple.com
Sat Apr 1 00:49:45 GMT 2006
On Fri, 2006-03-31 at 16:23 -0800, HH wrote:
> I have the following validation on and 'Order' model:
>
> validates_presence_of :order_lines, :message => 'missing one or more
> products.', :on => :save
>
> Ok, great. An order has to have products. Ok.
>
> Problem is, there are some old orders that don't have lines (don't ask) and
> in the admin tool we need to be able to work on these orders.
>
> Problem is that we can't save them since they technically fail validation.
> In the admin tool I want to be able to get around this.
>
> I'm using two methods to update order status, depending on if we're doing
> lots of 'em at a time:
>
> Order.update(params[:item].keys, params[:item].values)
>
> Or just one:
>
> @order = Order.find(params[:id])
> @order.update_attributes(params[:order])
>
> So, can anyone offer any advice in this scenario to bypass validations and
> update the objects/save them?
>
----
maybe I am dense but couldn't you just use sql to add what you need - be
they columns or rows ? ...i.e. insert into ... where ...
Craig
More information about the Rails
mailing list