`
Enn
  • 浏览: 28324 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论
文章列表
1.部署时遇到 HTTP 400 错误      找了半天才发现 是URL路径里用了下划线导致了这个问题。URL不能包含下划线…… 还真没注意这个东西。 2.过滤掉html标签 RAILS提供了方法  strip_tags。  自己还写了半天正则。。 餐具 3.从formbuilder中直接获取对象 form_for(@user) do |f| f.text_field :name == f.object.name end 动态创建nested_attributes def link_to_add_fields(name, f, association) ...
原文 http://hungred.com/how-to/jquery-javascript-css-important/ 关键点 jQuery('#id').css('cssText', 'height: 200px !important');
Helper方法用于虚拟属性的时间转换。 module Admin::TimeFormatsHelper # hh:mm:ss => seconds def forward_time_convert(time_virtual) time_collect = time_virtual.split(":") time_collect[0].to_i*3600 + time_collect[1].to_i*60 + time_collect[2].to_i end # seconds => hh:mm:ss ...
class Order has_many :order_informations accepts_nested_attributes_for :order_informations end class OrderInformation belongs_to :order validates_presence_of :quantity end 使用 accepts_nested_attributes_for 后发现quantity的非空校验总是无法正确显示i18n后的效果。 后来用 @order.errors.inpect 查看才发现 ...
$("#search").click(function () { $(".tree").jstree("search",$("#search_str").val()); }); "search"就是api中提供的那些方法 这样调用 /* METHOD TWO */ jQuery.jstree._reference(needle) /* NEEDLE can be a DOM node or selector for the container or ...
Rails3中Unobtrusive Javascript的核心是rails.js文件。当你新建一个RAILS的应用时 这个文件就和Rails2中prototype.js一样直接在public/javascript下创建了。默认的文件是prototype的实现,但也有官方的rails.js jQuery version版本。 之后按老办法把这个写到Layout里 <%= javascript_include_tag :defaults %> 特别提醒一下用jQuery版本的。一定要让jQuery在rails.js前加载。否则就会失效,程序也就表现出莫名其妙的样子 例如d ...
$(function () { $("#search").click(function () { $("#taxon_tree").jstree("search",$("#search_str").val()); }); $("#taxon_tree") .jstree({ "plugins" : [ "themes", "html_data", "search" ...
由于rails3不再死绑prototype 一些之前默认会加载好的东西就需要自己来了 多次碰到no routes match问题都是因为rails.js没有加载 …… 今天加了一个新的js进来 顺便动了下js文件的顺序  就再次餐具了 再加一个 rails.js一定要在jquery后面加载…… rails form_for 配置导致的no routes match 问题 当对一个已保存的对象进行操作时 这样配置form_for 总会出现 no routes match错误 form_for(@object, :url => other_operate_objects_pat ...
相关工具用的是 jstree 和 ancestry 就是个helper 遍历tree输出的方法 关键在于raw方法 rails3里content_tag貌似内置了自动转义 需要加上这个方法才可以正确输出html def tree_traversal(nodes, node_layer_array = []) return "" if nodes.blank? items = "" nodes.each do |node| item = link_to(node.name, edit_organ ...
查找出对象为一段html时 查找this的子对象用children无效 要用find。 $.each($("#sortable .template"),function(i,n){ alert($(this).find(".step_name").attr('name')); }); 在某段js总是莫名其妙的不能执行时 到页面上看看js 很有可能是因为一些 不可见的乱码掺杂在里面…… 残念了一个小时才发现。。 页面上获取鼠标单击时位置 顺便以这个位置为原点显示个弹出层~ 自动判断 如果超出浏览器高度则反方向弹出层 370为弹出层高度 ...
1.所有新项目都要先创建 .gitignore文件 用于控制垃圾文件的提交 在有新的插件加入生成文件时记得随时更新 下面是一份相对较全的gitignore文件 # OS generated files # ###################### .DS_Store? ehthumbs.db Thumbs.db # Config files # ################ /config/database.yml /config/email.yml # Logs and databases # ###################### *.log ...
Delayed_job plugin是一个健壮的稳定的用于在后台运行任务的解决方案。 下面的例子中,使用一个邮件群发的程序来做演示。如下图,点击'deliver'后,将开始发送邮件.例子中每个请求大概需要10秒的时间来执行,对使用者来说,点一个链接要等待10多秒显然太久了. 像这样的执行时间较长的请求,最好的办法就是放到后台执行.接下来,使用Delayed_job来实现这个功能。 安装 官方发布的Delayed_job可以在这里找到tobi’s Github pages,这上面有许多的分支,最好选择由collectiveidea提供的分支,这个分支功能更新也更完善,并且提供了一个生成脚本, ...
1.Label与Textarea顶部对齐 label与textarea默认是底部对齐,如果textarea的行数(rows)很多就很不美观。 在label中加入样式 vertical-align:top,就能使文字与textarea顶部对齐了。 例如: <label style="vertical-align:top" >评论内容:</label><textarea name="content" cols="60"></textarea> 2.页面布局宽度自适应 以两栏为例(A ...
document.observe('dom:loaded', function(){ $('panel_edit').observe('click', function(event){ shadow_show(this.getAttribute('name')); }); $('exit').observe('click', function(event){ hide_all(this.getAttribute('name')); }); }); function shadow_show(panel_id){ ...
初次接触Rspec 发现网上基本资料少的可怜 找到点啥先记下备用~ assert_template 测试是否装载了正确的view assert_tag 'form',:attributes=>{:action=>'/admin/....'} 测试View中是否有这表单,form也可以是div,td,input等html元素。 assert_response :redirect assert_redirected_to :action=>'index' 重定向 assigns(:author).first_name :assign是辅助方法,检查author实例变量的赋 ...
Global site tag (gtag.js) - Google Analytics