问题列表 - 第49639页

在Rails 3中的en.yml中自定义日期时间格式

根据http://guides.rubyonrails.org/i18n.html#adding-date-time-formats上的文档,要求特定日期格式的最佳方法是在/config/locales/en.yml中定义它们. .我已将此文件复制并粘贴:https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml到我的locales目录.

我做了一些改动(仅用于强调的星号):

"en-US":
  date:
    formats:
      default: "%Y-%m-%d"
      **short: "short %b %d"**
Run Code Online (Sandbox Code Playgroud)

time:
    formats:
      default: "%a, %d %b %Y %H:%M:%S %z "
      **short: "short %B %d, %Y"**
Run Code Online (Sandbox Code Playgroud)

在我的部分:

<%= l item.create_date, :format => :short %>
Run Code Online (Sandbox Code Playgroud)

其中create_date是我的项目数据库中的日期时间行.

我重新启动了我的服务器,但仍然得到这样的日期:15月00日00:00

我觉得这是因为我既不使用日期也不使用时间.我找不到datetime的"short"或"long"的定义.我尝试通过添加以下代码将其添加到此文件中:

datetime:
    formats:
      short: "short %B %d, %Y"
Run Code Online (Sandbox Code Playgroud)

没运气.我错过了什么 我觉得我直接按照说明操作.谢谢!

datetime internationalization ruby-on-rails-3

23
推荐指数
3
解决办法
2万
查看次数

核心数据迁移:属性映射值表达式

我目前在我的实体上有一个cardType属性,在旧模型中可以是"Math","Image"或"Text".在新模型中,我将只使用"Math"和"Text"并且还具有hasImage属性,如果旧的cardType是Image(我想要更改为"Text"),我想将其设置为true.

最后,我有一组另一个实体,"卡片",其中一个集合可以与一个套牌相关联,并且在每个实体中,我也将拥有hasImage,如果套牌为"我想要设置为真"图像"之前输入.

这是否可以使用我在两个版本之间创建的映射模型中的值表达式,还是我必须做其他事情?

我找不到任何文件告诉我价值表达中究竟有什么可能(Apple的文档 - http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/CoreDataVersioning/Articles/vmMappingOverview.html% 23 // apple_ref/doc/uid/TP40004735-SW3 - 只有一个非常简单的转换).如果我必须做别的事,会是什么?这看起来很简单,表达式应该能够做到.

migration xcode core-data ios mapping-model

4
推荐指数
1
解决办法
5809
查看次数

如何配置Microsoft Enterprise Library日志记录应用程序块以处理任何日志记录类别?

我正在尝试将Enterprise .NET通用基础结构库(Common.Logging)与Enterprise Library 4.1的Logging Application Block一起使用。根据docs,这是受支持的。

我遇到的问题是,当我尝试记录某些内容时(例如在本示例中,我在ASP.NET MVC应用程序中):

public ActionResult Index()
{
    ViewBag.Message = "Welcome to ASP.NET MVC!";

    ILog log = LogManager.GetCurrentClassLogger();
    log.Info("Hello world!");

    return View();
}
Run Code Online (Sandbox Code Playgroud)

我没有收到日志消息,而是在事件日志中遇到错误:

消息:类别“ TestApp.Controllers.HomeController”没有明确的映射。

好吧,Common.Logging中似乎没有任何选项可以设置默认类别,而且即使没有定义类别,我也无法弄清楚如何配置LoggingConfiguration接受任何类别。

这是我的LoggingConfiguration的一个片段:

<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
    defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
...
  <categorySources>
    <add switchValue="All" name="General">
      <listeners>
        <add name="Formatted EventLog TraceListener" />
        <add name="Email TraceListener" />
      </listeners>
    </add>
  </categorySources>
  <specialSources>
    <allEvents switchValue="All" name="All Events" />
    <notProcessed switchValue="All" name="Unprocessed Category" />
    <errors switchValue="All" name="Logging Errors &amp; Warnings">
      <listeners> …
Run Code Online (Sandbox Code Playgroud)

.net logging enterprise-library app-config web-config

4
推荐指数
1
解决办法
2万
查看次数

将数据写入JAVA中的.txt文件?

我想知道是否在JAVA中将计算数据写入文本文件.我的JAVA代码是基于GUI的gpa计算器.我只想添加一个JButton和ActionListener,它将类名,GPA点和计算出的GPA写入.txt文件.

这是我的JFrame驱动程序代码:

import javax.swing.JFrame;

public class Driver00

{

  public static void main(String[] args)

  {
    /*
     * Create a frame (outside box) and write what text
     * will be displayed as the frame title
     */
    JFrame frame = new JFrame("PHILIP MCQUITTY");

    // give frame a size
    frame.setSize(520, 375);

    // set location on the computer screen will frame appear
    frame.setLocation(400, 166);

    // use this so when you press X in corner, frame will close
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Add your panel to the frame. …
Run Code Online (Sandbox Code Playgroud)

java text file

3
推荐指数
1
解决办法
3万
查看次数

将数据库记录存储到数组中

我想创建一个数组,它将使用SELECT语句的查询保存从数据库中检索的记录.

要检索的记录有多个字段,如姓氏,名字,mi和另外20个字段.编码此函数的最佳方法是什么?

好吧,我已经跟随囚犯在下面给出了..下一个问题是我如何使用查询搜索这种数组?例如,我想搜索用户名..

php mysql arrays

14
推荐指数
1
解决办法
9万
查看次数

是否可以在ASP.NET中重定向期间设置cookie?

我正在使用ASP.NET.我要么添加或设置一个cookie(取决于是否HttpRequest包含具有指定密钥的cookie),然后立即调用Response.Redirect.cookie未设置.这是正确的行为吗?在具有302状态代码的http响应期间设置cookie是否相互排斥?

这是来源:

        if (context.HttpContext.Request.Browser.Cookies)
        {
            var cookies = context.HttpContext.Request.Cookies;
            var stateCookie = new HttpCookie(SR.session, clientState.SessionId.ToString());
            if (cookies.AllKeys.Contains(SR.session))
            {
                context.HttpContext.Response.Cookies.Set(stateCookie);
            }
            else
            {
                context.HttpContext.Response.Cookies.Add(stateCookie);
            }
        }
Run Code Online (Sandbox Code Playgroud)

以下是响应标头

  • X-AspNetMvc-Version - 2.0
  • 连接 - 关闭
  • 缓存控制 - 私有
  • 内容类型 - 文本/ html
  • 日期 - 2011年3月20日星期日03:48:04 GMT
  • 位置 - http:// localhost:3599/Home/Redirected
  • 服务器 - ASP.NET Development Server/9.0.0.0
  • X-AspNet-Version - 2.0.50727

asp.net response.redirect httpresponse httpcontext httpcookie

5
推荐指数
1
解决办法
1万
查看次数

互斥睡眠占用了大量的CPU

我用ruby-prof描述了我的基于事件机器的应用程序,发现了以下有趣内容:

                  5.28    0.00    5.28    0.00          4/4     Mutex#synchronize
90.72%   0.00%    5.28    0.00    5.28    0.00            4     Mutex#sleep

我认为ruby-prof只计算CPU滴答,因此我无法弄清楚为什么互斥锁睡眠会占用CPU时间.我假设它在内核级别上休眠而不计算光纤时间.有任何想法吗?更好的是,我希望Mutex#sleep能够释放对事件机器的控制权,因此它可以做其他事情.

ruby mutex eventmachine ruby-prof

5
推荐指数
1
解决办法
887
查看次数

"@model dynamic"在ASP.NET MVC3 .cshtml页面中有效吗?

我正在编写一个我在Mac OS X上运行的ASP.NET MVC3应用程序.它运行良好,但我有一个未解决的问题.我正在使用Razor语法.例如,这是登录页面的简化版本:

@model Livestream.LoginModel
<!DOCTYPE html>
<html>
<head>
    <title>Remote Observation</title>
    <link type="text/css" rel="stylesheet" media="all" href="/Content/CSS/main.css" /> 
</head>
<body>
    @{
        dynamic dave = "Sign In";
    }
    <div class='normal center'>
        <p><img src='/Content/images/logo.png' /></p>
        @using(Html.BeginForm("Login", "Main")) {
            <div class='loginBox'>
                 <p>Username<br />@Html.TextBoxFor(m => m.Username)</p>
                 <p>Password<br />@Html.PasswordFor(m => m.Password)</p>
                 <p><input type='submit' value='@dave'></p>
            </div>
        }
    </div>
    <script>
        document.getElementById('Username').focus();
    </script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

好的,所以没问题.它在Mac OS X和Linux上都很好用.

阅读评论后,这个职位由斯科特谷,我想我明白,我可以代替@model Livestream.LoginModel使用@model dynamic.当我尝试它时,它无法在OS X或Linux上运行.

鉴于我在ASP.NET中开发,它可能看起来很疯狂但我无法访问带有.NET的Windows机器来尝试这一点.我明显使用Mono.

我应该能够使用@model dynamic或者是否在那篇文章中误解了斯科特?还有什么我需要做的才能让它发挥作用吗?或者这是Mono中的一个错误?

我的应用程序使用的是.NET 4配置文件(CLR 4.0),因此它并不支持动态.我可以在代码中的其他位置使用动态. …

c# asp.net-mvc mono razor asp.net-mvc-3

3
推荐指数
1
解决办法
7062
查看次数

转换double值以生成Point类型

我想使用imagefrom位图在图片框中绘制一条曲线(二极管曲线).我现在遇到一个问题,我的点数据被保存为Double,保持这种状态非常重要.

例如,我的情节中的一个点是这样的:

电压:-0.175电流:-9.930625E-06

是的,这是一个双倍!现在我怎么能有一点要做的例子:

        Point[] ptarray = new Point[3];
        ptarray[0] = new Point(250, 250);
Run Code Online (Sandbox Code Playgroud)

是否有一个替代Point []接受双值?我有一个500x500的图片框.有没有办法将这些值转换为仍可以节省成本的有效点?我正在使用微安培(10 ^ -6)和电压!

c# double point

8
推荐指数
1
解决办法
2万
查看次数

100-continue在PUT请求中意味着什么?

我看到Expect:100-continue在某个PUT请求(上传文件)中,这是什么意思?

http

5
推荐指数
1
解决办法
3870
查看次数