我使用以下@font-face声明无法使用我的Rails 3.1应用程序.我把资产管道的字体在其所谓的"字体"自己的文件夹一起images与stylesheets和javascripts
这是我使用的声明(由Font Squirrel生成.)
@font-face {
font-family: 'ChunkFiveRegular';
src: url('Chunkfive-webfont.eot');
src: url('Chunkfive-webfont.eot?#iefix') format('embedded-opentype'),
url('Chunkfive-webfont.woff') format('woff'),
url('Chunkfive-webfont.ttf') format('truetype'),
url('Chunkfive-webfont.svg#ChunkFiveRegular') format('svg');
font-weight: normal;
font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)
有人在他们的Rails 3.1应用程序上成功使用@ font-face吗?
更新
我刚刚阅读了这个主题http://spin.atomicobject.com/2011/09/26/serving-fonts-in-rails-3-1/,它说url要font-url在声明中改变.不幸的是,这似乎没有用.
我有一个多维数组,如下所示:
[
[name, age, date, gender]
[name, age, date, gender]
[..]
]
Run Code Online (Sandbox Code Playgroud)
我想知道根据多种条件对这个数组进行排序的最佳方法......例如,我将如何根据年龄 首先按名称进行排序?
我正在搞乱sort这样的方法:
array.sort { |a,b| [ a[1], a[0] ] <=> [ b[1], b[0] ] }
Run Code Online (Sandbox Code Playgroud)
除此之外,我并不真正理解这种语法,我没有得到我期望的结果.我应该使用这种sort方法吗?我应该单独比较mapping阵列的结果吗?
问题:当我点击关联的操作时,它们是在现有嵌套属性的基础上创建的,而不是更新嵌套属性#updatefeatures_controller.rb
可能的原因:我认为问题在于我在Rails中缺乏理解form_for.我认为细分在我的视图中,如何呈现持久的嵌套属性,和/或我如何指定嵌套属性的id失败,导致它只是创建一个新的id
feature.rb
class Feature < ActiveRecord::Base
...
has_many :scenarios
accepts_nested_attributes_for :scenarios,
allow_destroy: true,
reject_if: :all_blank
...
end
Run Code Online (Sandbox Code Playgroud)
features_controller.rb
def update
...
project = Project.find(params[:project_id])
@feature = Feature.find(params[:id])
if @feature.update_attributes(feature_params)
# checking feature_params looks good...
# feature_params['scenarios'] => { <correct object hash> }
redirect_to project
else
render :edit
end
end
...
private
def feature_params
params.require(:feature).permit(:title, :narrative, :price, :eta, scenarios_attributes[:description, :_destroy])
end
Run Code Online (Sandbox Code Playgroud)
_form.html.haml(简体)
= form_for [@project, @feature] do |f|
... …Run Code Online (Sandbox Code Playgroud) ruby-on-rails nested-attributes nested-form-for ruby-on-rails-4
我在iOS和Android的移动网站上使用最精彩的JavaScript工具iScroll4 http://cubiq.org/iscroll-4.这是我的布局:

水平滚动区域使用iScroll4进行以下设置:
var myScroll = new iScroll('frame', { hScrollbar: false, vScrollbar: false, vScroll: false })
Run Code Online (Sandbox Code Playgroud)
水平滚动部分效果很好.此问题是当用户尝试向上或向下滚动页面时将手指放在水平滚动区域上时会发生的问题.所以我需要原生垂直滚动,并在同一区域上进行iScroll水平滚动.
到目前为止我尝试过:在iScroll代码中删除e.preventDefault()(允许本地滚动,但在BOTH轴中).删除e.preventDefault()然后禁用水平滚动页面宽度:
var touchMove;
document.ontouchstart = function(e){
touchMove = e.touches[0];
}
document.ontouchmove = function(e){
var theTouch = e.touches[0] || e.changedTouches[0];
var Xer = rs(touchMove.pageX - theTouch.pageX).toPos();
var Yer = rs(touchMove.pageY - theTouch.pageY).toPos();
touchMove = theTouch;
if(Yer > Xer){ e.preventDefault(); }
}
Run Code Online (Sandbox Code Playgroud)
这似乎无能为力.如何在水平滚动区域中允许原生垂直滚动,而不会丢失iScroll的水平滚动?我真的很难过.提前致谢.
(仅用于记录rs(foo).toPos()是一个使foo成为正数的函数,无论其值如何).
我的CSS动画的声明animation-play-state: paused上div:hover.问题是(至少在Chrome中),当悬停元素时,动画会断断续续/跳跃.
这是一个jsFiddle:http://jsfiddle.net/AHqLE/
有没有人经历过这个?
我在我的Users_controller中定义了:
layout "intro", only: [:new, :create]
这是我的布局: Intro.html.haml
!!! 5
%html{lang:"en"}
%head
%title Intro
= stylesheet_link_tag "application", :media => "all"
= javascript_include_tag "application"
= csrf_meta_tags
%body{style:"margin: 0"}
%header
= yield
%footer= debug(params)
Run Code Online (Sandbox Code Playgroud)
当我渲染一个要求intro作为布局的页面时,它嵌套在我的application.html.haml文件中,这是不好的.
有没有办法避免这种不受欢迎的布局嵌套?
提前致谢!
HTML:
<p class="greeting">
hello, my name is kevin. what's yours?
</p>
Run Code Online (Sandbox Code Playgroud)
jQuery的:
$("p.greeting").filter(function (){
return $this.text() === "my name is";
}).css("background", "green");
Run Code Online (Sandbox Code Playgroud)
我试图在<p class="greeting">标签中隔离"我的名字是"字样.任何人都可以帮助我使用jQuery,因为它似乎不起作用.谢谢.
有没有运气,使用TextMate包编译和运行Sublime Text 2中的CoffeeScript文件https://github.com/jashkenas/coffee-script-tmbundle
CoffeeScript.sublime建造
{
"path": "/usr/local/bin",
"cmd": ["coffee","$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.coffee"
}
Run Code Online (Sandbox Code Playgroud)
无论如何要在Sublime Text 2中启用编译和编译选定的文本命令?
浏览http://api.rubyonrails.org/classes/ActionDispatch/Cookies.html中的文档,并按如下方式设置Rails cookie:
cookies[:votes_left] = { :value => 3, :expires => 24.hours.from_now }
在我的浏览器(Chrome)中,它报告了正确的值,但是Invalid Date在Expires列(网络> Cookie)下给了我.
我是否错误地设定了日期?我已尝试过Time对象的变体,但仍然得到相同的结果,一个带有无效过期的正确值cookie.
我正在使用Gmaps4Rails gem,无法弄清楚如何调整默认缩放设置.在我看来,我有以下代码:
<%= gmaps({
"map_options" => {"auto_adjust" => false, "auto_zoom" => false, "zoom" => 15 },
"markers" => {"data" => @json }
})
%>
Run Code Online (Sandbox Code Playgroud)
我知道这已被多次询问和回答,但也许我只是没有看到任何建议?我错过了一些完全明显的东西吗 我为重新提出这个问题而道歉.
谢谢,凯文
编辑
我没有正确地注释掉gmaps的默认实例,它覆盖了我的自定义设置.感谢所有帮助@apneadiving!
我正在努力(我相信是)一个范围问题.这是我的代码示例:
$(document).ready(function() {
var counter = 0;
function scrollTweets() {
counter ++;
// rest of code
}
...
)}; // end of document ready
Run Code Online (Sandbox Code Playgroud)
当我counter在Chrome的Javascript控制台中查找变量时,它返回"ReferencedError".但是,当我var从上面的代码中删除并键入counter控制台时,它返回值.为什么是这样?
我认为理解这个简单的概念将使我能够解决在开发过程中似乎突然出现的问题.这只是Chrome的一个范围问题吗?我不必要地将所有内容包装在$(document).ready"功能"中吗?
javascript ×3
css ×2
css3 ×2
jquery ×2
ruby ×2
android ×1
arrays ×1
coffeescript ×1
controllers ×1
cookies ×1
filter ×1
font-face ×1
gmaps4rails ×1
google-maps ×1
ios ×1
iscroll4 ×1
layout ×1
mobile ×1
render ×1
sass ×1
scope ×1
session ×1
sorting ×1
sublimetext ×1
sublimetext2 ×1
view ×1