Topic: HELP TO OPTIMISE MY METHOD

hi ...
help me to optimise the below method..
Thanks a bunch

def designation_list
#--------------------
  if request.post? and params[:id]
   
    department = Department.find_by_id(params[:id])
     
    @designations = Designation.find_by_sql "select * from designation where company_id = #{department.company_id} and department_id = 0 order by designation_name asc"
     
    @specific_designation = Designation.find_by_sql "select * from designation where company_id = #{department.company_id} and department_id = #{params[:id]} order by designation_name asc"
     
      #if department sepcific designations not exists
      if @specific_designation.length == 0
         
        render :update  do |page|
          page.replace_html "rolesadd-#{department.company_id}",:partial => 'desig',:locals => {:designations =>   @designations ,:id => department.id, :company => false }
          page.replace_html "roleslist-#{department.company_id}",:partial => 'designations',:locals => {:designations => @designations ,:id => department.id, :company => false }
        end
       
      #else
      else
         
        designations_list = Array.new
        render :update  do |page|
             
          @designations.each do |f|
            designations_list << f
          end
         
          @specific_designation.each do |f|
            designations_list << f
          end
         
          designations_list = designations_list.sort_by {|h| h.designation_name.downcase}
          page.replace_html "rolesadd-#{department.company_id}",:partial => 'desig',:locals => {:designations => designations_list ,:id => department.id, :company => false }
          page.replace_html "roleslist-#{department.company_id}",:partial => 'designations',:locals => {:designations => designations_list ,:id => department.id, :company => false }
         
        end
       
      end
     
    end
end

Re: HELP TO OPTIMISE MY METHOD

Optimize is a very broad term. What would your goal of the optimization be? Easier to read? Faster? Less resource intensive?

Also use the [ code ] ... [ /code ] (no spaces) tags to make the code easier to read.

Chris

Re: HELP TO OPTIMISE MY METHOD

hi thanks for the reply
i want to simplyfy the query