Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ActiveRecord::Base.transaction do
- new_ids =
- ActiveRecord::Base.connection.execute(
- params[:sql]).column_values(0)
- #get ids - 0th column in result-table
- same_ids = (new_ids.sort == (params[:ids].to_a.collect{|id|
- id.to_i}).sort)
- if !same_ids
- result = ActiveRecord::Base.connection.execute(params[:sql])
- model = params[:model].camelize.classify.constantize
- fields = result.fields
- recordset = model.where(id: new_ids).order_as_specified(id: new_ids)
- ...
- end
- raise ActiveRecord::Rollback #sql must be run inside transaction for security
- end
- if !same_ids
- ... (Handle the change)
Add Comment
Please, Sign In to add comment