`
minixx77
  • 浏览: 10400 次
  • 性别: Icon_minigender_2
  • 来自: 杭州
社区版块
存档分类
最新评论
文章列表
加载其他页面的内容 方法一: <script type="text/javascript">     $(function (){         $('a.dialog').click(function() {             var url = $(this).attr('href');             var dialog = $('<div style="display:none"></div>').appendTo('body');             dialog.load(url, {} ...
自定义验证: 可以自定义validate(), 这个方法在每次保存数据时都会被调用. 如: 代码  def validate   if name.blank? && email.blank?   errors.add_to_base("You mustspecify a name or an email address")   end   end  同时也可以自定义 v ...
1.Controller中的公開(public)方法都是Action,也就是可以讓瀏覽器呼叫使用的動作。使用protected或private可以避免內部方法被當做Action使用。 2.def create   @event = Event.new(params[:event])   if @event.save     redirect_to :action => :index   else    ...
问题:在action1中设置了flash[:notice]值,当点击一个链接跳到另外一个action2的时候,flash[:notice]还会显示,只有再次点击其它的链接,flash[:notice]才会消失。 原因:flash[:notice] is meant only for redirect action, because the message is only cleared after at the end of redirected view request. So if you don’t redirect the request, and you click on the ne ...
ruby 环境变量的设定 config/environment.rb $PON_IP = "192.168.1.31"(每个现场自己配IP地址) 前台取 :host=> $PON_IP

ruby 习题

    博客分类:
  • ruby
#1.1 #生成100个0到99之间的随机整数,找出它们之中的最大者和最小者,并统计大于50的整数个数 a = [] sum = 0 0.upto(99) {|i| j = rand(i).to_i a << j sum +=1 if j > 50 } max = a.max min = a.min p a puts max,min,sum #1.2 #1到11有4个"1",1中一个"1",10中一个"1",11中两个"1",1000中,有多少个"1" a = (1 ...
s=["ruby is an interesting language"] a = s.split(/ /) a.sort_by{|i| i}
已存在的数据,执行更新,如果没有存在,则插入数据。 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_mea ...
问题:   表格溢出外框。。 解决方法:   table{table-layout: fixed;}   td{word-break: break-all; word-wrap:break-word;}   文字自动换行。
Global site tag (gtag.js) - Google Analytics