使用rails 5.0.0为Web应用程序构建简单的计时卡模块。我的问题是我怎么去有关修改后自动被护栏呈现的形式脚手架Rails修改脚手架表格
rails g scaffold Timesheet user:string clock:string time:datetime
=== new.html.erb文件===
<%= render 'form', timesheet: @timesheet %>
在用户想要字符串添加<%= current_user.email%>并在时钟字符串中添加一个下拉列表?做这个的最好方式是什么?已经有数据库表到位等等
示意图下
提前感谢!
在控制器中,您可以:'Timesheet.new(user:current_user.email)'(在new-action中替换'Timesheet.new')来预设值。不过,用户仍然可以在表单中更改它。 – ollpu