我在Heroku Cedar上部署了一个Rails 3.1应用程序.由于某些原因,我的静态图像资产没有被提供:
2011-06-23T18:14:13+00:00 app[web.1]: Started GET "/assets/me_reminder-30f9d1dead32e12238888adbee4b92d3.png" for 98.207.60.248 at 2011-06-23 18:14:13 +0000
2011-06-23T18:14:13+00:00 app[web.1]: Served asset /me_reminder-30f9d1dead32e12238888adbee4b92d3.png - 200 OK (0ms) (pid 1)
2011-06-23T18:14:13+00:00 app[web.1]: cache: [GET /assets/me_reminder-30f9d1dead32e12238888adbee4b92d3.png] miss, store
2011-06-23T18:14:13+00:00 heroku[router]: GET xxxx.herokuapp.com/assets/me_reminder-30f9d1dead32e12238888adbee4b92d3.png dyno=web.1 queue=0 wait=0ms service=35ms status=200 bytes=0
Run Code Online (Sandbox Code Playgroud)
如您所见,它返回0字节的内容.不用说,没有图像显示.
但是,我所有其他静态资产(css,javascripts)都正确提供.知道这里有什么不对吗?
顺便说一句,我在heroku上有另一个Rails 3.1应用程序,它运行得很好,所以我不认为这是链轮等问题.
谢谢.
我正在使用Rails 3.1RC4和默认的SASS设置.我有以下文件
application.css.scss
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require_tree .
*/
Run Code Online (Sandbox Code Playgroud)
_variables.css.scss
$var1 : somevalue;
...
Run Code Online (Sandbox Code Playgroud)
site_layout.css.scss
@import "variables";
... Some Sass Code
Run Code Online (Sandbox Code Playgroud)
但我无法访问site_layout中_variables.css.scss中定义的变量.我究竟做错了什么?Rails显然找到了变量文件,因为它不会抛出"找不到文件"错误,如果我更改导入文件名就会出错.这些变量还没有结转.
有任何想法吗?
谢谢!
我正在尝试对iContact API执行请求,该请求需要使用自定义标头进行身份验证(http://developer.icontact.com/documentation/authenticate-requests).这是我的代码:
$.ajax({
type: "GET",
url: "https://app.icontact.com/icp/a/",
contentType: "application/json",
beforeSend: function(jqXHR, settings){
jqXHR.setRequestHeader("Accept", "application/json");
jqXHR.setRequestHeader("Api-Version", iContact_API_version);
jqXHR.setRequestHeader("Api-AppId", iContact_appID);
jqXHR.setRequestHeader("Api-Username", iContact_username);
jqXHR.setRequestHeader("API-Password", iContact_appPassword);}
});
Run Code Online (Sandbox Code Playgroud)
由于某种原因,请求没有通过.但是,当我手动执行相同的请求(使用Chrome REST控制台)时,它可以正常工作.如果我取出自定义标头(API-*),请求会通过但当然身份验证失败,我会回到常规HTML页面.
我切换到Firefox并检查了请求/响应标头:
请求:
Host app.icontact.com
User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
Origin http://184.72.61.244
Access-Control-Request-Me... GET
Access-Control-Request-He... api-appid,api-password,api-username,api-version
Run Code Online (Sandbox Code Playgroud)
响应:
HTTP/1.1 302 Found
Date: Tue, 14 Jun 2011 23:43:56 GMT
Server: Apache/2.2.9 (Debian)
Set-Cookie: intellicontact_phpsess=1c7ca333017b47f46edd893dae584781; path=/; domain=.icontact.com; secure; HttpOnly …Run Code Online (Sandbox Code Playgroud) 我想在导航栏中使用自定义项目作为后退按钮.
UIImage *backButtonImage = [UIImage imageNamed:@"backbutton.png"];
UIBarButtonItem *customItem = [[UIBarButtonItem alloc] initWithImage:backButtonImage style:UIBarButtonItemStylePlain target:nil action:nil];
[self.navigationItem setBackBarButtonItem: customItem];
[customItem release];
Run Code Online (Sandbox Code Playgroud)
我最终得到的是我周围有边框的图像.它看起来像这样(我的图像是后退按钮):

我该怎样摆脱边界?我究竟做错了什么?
我拼命想在Javascript中手动创建一个JSON样式的数组,通过jQuery的AJAX方法通过网络发送.
var fieldsobj = {fields:[]}
$(".fact_field", fact).each(function(index, field){
var index = $(field).attr("data-index");
var name = $(".fact_field_label", field).text().trim();
var value = $(".fact_field_value", field).text().trim();
fieldsobj["fields"].push({index:index, name:name, value:value});
});
//...
$.ajax({
type: 'PUT',
url: url,
data: fieldsobj,
success: function(data){...
},
complete: function(){...
}
});
Run Code Online (Sandbox Code Playgroud)
我想要的是以下内容:
{fields => [{index:0, name:1, value:2},{...},{...}]}
Run Code Online (Sandbox Code Playgroud)
我得到的是这个:
{"fields"=>{"0"=>{...}, "1"=>{..}, "2"=>{...}, "3"=>{...}}
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
这是我第一次与Sinatra合作,我无法在测试中使用会话.我有enable :sessions我的应用程序.
我试过了:
get "/controller/something", {}, "rack.session" => {:session => "Aa"}
Run Code Online (Sandbox Code Playgroud)
要么
get "/controller/something", {}, "session" => {:session => "Aa"}
Run Code Online (Sandbox Code Playgroud)
但是我的请求中没有设置会话变量.我环顾网络并尝试了几个建议,但似乎没有任何效果.我错过了什么吗?
谢谢!
我有大约 60,000 个小图像文件(总大小为 200mb),我想将它们从我的项目存储库中移出到 Amazon S3。
我尝试过 s3fs ( http://code.google.com/p/s3fs/ ),通过 Mac OS X 上的传输以及 Amazon AWS S3 网络上传器安装 S3。不幸的是,所有这些似乎都需要很长时间,超过一两天才能完成任务。
有没有更好的办法?
我正在使用Ruby on Rails开发一个站点.我想分别开发REST API(JSON)以最大限度地提高性能,Rails堆栈只会带走太多.
那里有任何性能基准吗?您认为会产生最佳表现?我目前正在考虑以下内容,因为这是我所经历的.还有什么我应该考虑的吗?它应该是轻量级的.
谢谢!
在我的routes.rb中:
resources :posts do
get "test"
end
Run Code Online (Sandbox Code Playgroud)
这会生成通常的RESTful路由/post/:id/....但是,我也得到了/post/:post_id/test.
现在我的问题是,有时参数名为:id,有时它是:post_id.我怎样才能让它变得均匀?
谢谢!