`
minixx77
  • 浏览: 10409 次
  • 性别: Icon_minigender_2
  • 来自: 杭州
社区版块
存档分类
最新评论

find_or_create_by_XX

阅读更多
已存在的数据,执行更新,如果没有存在,则插入数据。

view:
<%=g.d f.select "#{d[:cityid]}-#{d[:device_manu]}",[["",""],["TL1","tl1"],["SNMP","snmp"]], {:selected =>d[:means] }%>

model:
def self.update_collect_means(collect_means)
      collect_means.each_pair do |id,means|
      update_all("id='#{id}'","means = '#{means}'")
    end
  end

controller:
  def update_collect_means
    params[:collect_means].each_pair do |id,means|
      unless means.blank?
        keys = id.split("-")
        #collect_mean = CollectMean.new(:cityid => keys[0],:device_manu => keys[1],:means => "#{means}")
        collect_mean =     CollectMean.find_or_create_by_cityid_and_device_manu_and_means(:cityid => keys[0], :device_manu => keys[1],:means => "#{means}")
        collect_mean.save
      end
    end
    #CollectMean.update_collect_means(params[:collect_means])
    flash[:notice] = "更新采集方式成功。"
    redirect_to :action => :index
  end
分享到:
评论

相关推荐

    逆向工程权威指南 英文版

    So just find filename_EN.tex file you want to translate, copy to filename_XX.tex (where XX is your language) and replace English text by yours. No special TeX/LaTeX knowledge is needed. Then just ...

    ap6212a0_a33_sc3817r_神舟验证版本_借用nvram_ap6210这个配置文件_20170626_1834没有外层目录.7z

    # $(call find-copy-subdir-files,*,device/softwinner/polaris-common/rild/usb_modeswitch.d,system/etc/usb_modeswitch.d) PRODUCT_PROPERTY_OVERRIDES += \ ro.sw.embeded.telephony = false PRODUCT_...

    ap6212a0_a33_sc3817r_服务器验证通过_bt已经通了_wifi需要修改配置_需要再次验证_20170626_1549.7z

    # $(call find-copy-subdir-files,*,device/softwinner/polaris-common/rild/usb_modeswitch.d,system/etc/usb_modeswitch.d) PRODUCT_PROPERTY_OVERRIDES += \ ro.sw.embeded.telephony = false PRODUCT_...

    ehlib_vcl_src_9_3.26

    order, columns width, sortmarkers, row height) in/from registry or ini file. Allows to show hint (ToolTips) for text that don't fit in the cell. Allows to export data to Text, Csv, HTML, RTF, XLS ...

    uboott移植实验手册及技术文档

    Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) if ((start_addr & NAND_BLOCK_MASK) || (size & NAND_BLOCK_MASK)) { return -1; /* invalid alignment */ } ...

    opengl画图程序附带源代码

    int xx,yy; int chakela; int amd[200][200]; int rmd[200][200]; int gmd[200][200]; int bmd[200][200]; int yanser,yanseg,yanseb; FILE *zuojian; bool keys[256]; // Array Used For The Keyboard Routine ...

    kgb档案压缩console版+源码

    P in equation (1), that you can find either x from y or y from x. Note also that both computations can be done incrementally. As the leading characters of y are known, the range of possible x narrows,...

    OutlookAttachView v2.73

    or to skip) by adding * character to the folder string, for example: Personal Folders\Inbox* * Version 1.71 o Fixed OutlookAttachView to be able to scan the public folders of Exchange server. * ...

    EhLib5.0.13 最新的ehlib源码

    By default Delphi (5, 6 and 7) places compiled files to the &lt;Delphi path&gt;\Projects\Bpl directory and this directory already present in the search PATH. But if you overwrite default BPL directory ...

    EhLib 9.1.024

    order, columns width, sortmarkers, row height) in/from registry or ini file. Allows to show hint (ToolTips) for text that don't fit in the cell. Allows to export data to Text, Csv, HTML, RTF, XLS ...

    apktool documentation

    After you find a framework file you could pull it via adb pull /path/to/file or use a file manager application. After you have the file locally, pay attention to how Apktool installs it. The number ...

    grub4dos-V0.4.6a-2017-02-04更新

    已经发现的问题是执行 find,不返回 (hd0);精简 PE 加载映像文件死机。 2.解决了FDD 模式的 u 盘,执行 find 时返回 (fd0,n) 的问题。 3.修正了 menu.lst 中 0PE.ISO 的默认位置。 4.usb2.0 驱动通过菜单或...

    VB.NET Developer's Guide(4574).pdf

    a value or whether we are using the Call statement. It makes the code much more readable and is a new standard for VB programmers that is consistent with the standard that nearly all other languages ...

Global site tag (gtag.js) - Google Analytics