我正在使用Play 2.4.0并且我一直在尝试按照主页中的教程:https: //playframework.com/,这是针对Play 2.3以及解决了有关Ebean ORM更改的几个问题之后版本2.3到2.4,我遇到以下错误:
Compilation error
value at is not a member of controllers.ReverseAssets
Run Code Online (Sandbox Code Playgroud)
我的index.scala.html:
@(message: String)
@main("Welcome to Play") {
<script type='text/javascript' src="@routes.Assets.at("javascripts/index.js")"></script>
<form action="@routes.Application.addPerson()" method="post">
<input type="text" name="name" />
<button>Add Person</button>
</form>
<ul id="persons">
</ul>
}
Run Code Online (Sandbox Code Playgroud)
我的routes档案:
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
GET / controllers.Application.index()
POST /person controllers.Application.addPerson()
GET /persons controllers.Application.getPersons()
# Map static resources from the /public …Run Code Online (Sandbox Code Playgroud) 我可以在Java中使用哪种数据类型来保存当前日期和时间?我想将日期时间存储在数据库中,并在java bean中有一个字段来保存它.
是java.util.Date吗?
鉴于我有下一个型号:
user.rb
has_many :favorites, dependent: :destroy
has_many :sports, through: :favorites
Run Code Online (Sandbox Code Playgroud)
sport.rb
has_many :favorites, dependent: :destroy
has_many :users, through: :favorites
Run Code Online (Sandbox Code Playgroud)
在创建新用户的表单中,有一个体育复选框列表,在用户验证中我想验证至少选择了一个.
我是这样做的:
在用户控制器中创建操作:
@user = User.new(params[:user])
@user.sports << Sport.find(params[:sports]) unless params[:sports].nil?
if @user.save ...
Run Code Online (Sandbox Code Playgroud)
在用户模型中
validate :user_must_select_sport
def user_must_select_sport
if sports.empty?
errors.add(:Sport, "You have to select at least 1 sport")
end
end
Run Code Online (Sandbox Code Playgroud)
它确实有效,但我猜它必须是一个更好的方法.我很感激任何帮助.
在我的spec/models/user_spec.rb中我有下一个:
require 'spec_helper'
describe User do
before { 5.times { FactoryGirl.create(:sport) } }
before { let(:user) { FactoryGirl.create(:user) } }
...
end
Run Code Online (Sandbox Code Playgroud)
但是当运行我的user_spec.rb时,我收到此错误:
Failure/Error: before { let(:user) { FactoryGirl.create(:user) } }
NoMethodError:
undefined method `let' for #<RSpec::Core::ExampleGroup::Nested_1:0x000001043033b0>
Run Code Online (Sandbox Code Playgroud)
这很奇怪,因为我的规格一直在运作,直到现在,我没有改变任何东西......
这是我的gemfile:https://gist.github.com/4690919
这是我的spec_helper.rb:https://gist.github.com/4690935
我很感激任何帮助,谢谢
List我正在尝试在 a和 a之间创建绑定DataGrid。我还没有在网上找到有效的解决方案,这很奇怪。
在我的小例子中,我创建了一个具有两个属性和 的List对象:publicAgeName
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
public ObservableCollection<Person> Collection { get; set; }
public List<Person> Persons { get; set; }
private void WindowLoaded(object sender, RoutedEventArgs e)
{
this.Persons = new List<Person>();
for (int i = 0; i != 35; i++)
{
this.Persons.Add(new Person() {Age = i, Name = i.ToString()});
}
this.Collection = new ObservableCollection<Person>(this.Persons); …Run Code Online (Sandbox Code Playgroud) 我正在使用Figaro gem但它只在我访问内部的env变量时才有效config/database.yml:
<%= ENV["MYSQL_USERNAME"] %>
Run Code Online (Sandbox Code Playgroud)
但不是当我按照文档指定的方式尝试时:
ENV["MYSQL_USERNAME"]
Run Code Online (Sandbox Code Playgroud)
要么
Figaro.env.mysql_username
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么会这样?