我有这些联想:
class Course < ActiveRecord::Base
has_many :signup
has_many :user, :through => :signup
accepts_nested_attributes_for :signup
end
class User < ActiveRecord::Base
has_many :signup
has_many :course, :through => :signup
accepts_nested_attributes_for :signup
end
class Signup < ActiveRecord::Base
belongs_to :course
belongs_to :user
end
Run Code Online (Sandbox Code Playgroud)
现在,我想为"注册"自定义ActiveAdmin表单,因此它显示了课程的标题和用户的名称作为选择而不是文本字段.
默认表单已经这样做,但是我需要进一步自定义表单,我无法重现默认表单.
我是heroku的新手,我无法推动我的rails项目.
我可以成功登录到heroku,我有钥匙
Keys
ssh-rsa AAAAB3NzaC...oPiDGoh0Gt root@Slava-System-Product-Name
Run Code Online (Sandbox Code Playgroud)
但是当git push heroku master我收到你的时候
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud) 我正在为我的春季休息服务编写测试用例.我们在控制器中有一个put服务,语法如下
@RequestMapping(value="/update", method=RequestMethod.PUT)
public @ResponseBody List<PaidUpResponse> updateStatus(
@RequestBody @Valid PaidUpRequest paidUpRequest,
HttpServletRequest request, HttpServletResponse response) {
}
Run Code Online (Sandbox Code Playgroud)
编写测试用例,我使用了以下方法
mockMvc.perform(put("/update").contentType(UnitTestUtil.APPLICATION_JSON_UTF8)
.content(UnitTestUtil.convertObjectToJsonBytes(request)))
.andExpect(status().isOk());
Run Code Online (Sandbox Code Playgroud)
但它给出了编译错误,说"方法put(String)未定义".你能建议我怎么测试put方法吗?
昨天我用carrierwav做了一些经验,一切正常,但在图像标签上通常只有图像显示轨道也显示孔模型,created_at等等.在这里你可以看到它!
所以现在我的看法:
<% @patient.treatments.each do |treatment| %>
<tr>
<td><%= treatment.category.try(:typ) %></td>
<td><%= treatment.content %></td>
<td><%= treatment.day %></td>
<td><div class="arrow"></div></td>
</tr>
<tr>
<td colspan="5">
<%= link_to 'Löschen', [treatment.patient, treatment],
:confirm => 'Sind sie sicher?',
:method => :delete %>
<%= treatment.paintings.each do |paint| %>
<%= image_tag paint.name %>
<% end %>
</td>
</tr>
<% end %>
Run Code Online (Sandbox Code Playgroud)
问题必须在于 <%= image_tag paint.name %>
困惑.请看下面
$ git push heroku master
Could not create directory '/c/Users/Dipak/Git/.ssh'.
The authenticity of host 'heroku.com (50.19.85.156)' can't be established.
RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/c/Users/Dipak/Git/.ssh/known_hosts).
Permission denied (publickey).
fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)
任何想法如何解决问题?
我必须编写一个方法,它能够在数据库中找到随机假期.但是当我在测试中使用这部分时
Random id = new Random();
vacationId = id.nextInt(2500);
Run Code Online (Sandbox Code Playgroud)
我得到NullPoiterExeption.但是当我打印时
vacationId = 2500;
Run Code Online (Sandbox Code Playgroud)
或其他一些数字,一切都很好.
这是整个方法
public Vacation findRandomVacation() {
Integer vacationId = null;
Query query = entityManager.createQuery("from Vacation v where v.id = :id")
.setParameter("id", vacationId);
if ( query.getResultList().isEmpty()) {
Random id = new Random();
vacationId = id.nextInt(2500);
query = entityManager.createQuery("from Vacation v where v.id = :id")
.setParameter("id", vacationId);
}
return (Vacation) query.getResultList().get(0);
}
Run Code Online (Sandbox Code Playgroud)
这是测试的主体:
@Test
public void testVacationApprovalResultDao () {
Vacation testVacation = findRandomVacation();
VacationApproval testVacationApproval = findVacationApprovalDAO(testVacation); …Run Code Online (Sandbox Code Playgroud) 我在尝试从外部文件中获取变量值时遇到问题.我的问题是:是否有可能从for中读取文件中的值然后使用cut命令我可以在=之前得到信息,这将是变量之后的=将是值.这是我在下面尝试但不允许的:
for i in `cat $1`
do
`echo $i | cut -d= -f1`=`echo $i | cut -d= -f2`
done
Run Code Online (Sandbox Code Playgroud)
$ 1是作为参数传递的文件,它有3行,其中行有一个变量,格式值为variable = value.有没有办法我可以这样做,而不是需要获取变量名称,然后另一个条件为这些变量的值?或者即使我的代码是正确的,但只需要改变一些东西.