![](/img/trans.png)
[英]What is the most effecient way to get and view commonly used data inside a Rails application?
[英]Rails recommended way to deal with commonly used html boilerplate
例如,在下表中,我在整个应用程序中反复使用动作,但我不确定如何将其干燥,无论是局部视图还是Rails帮助器(对于处理html片段似乎都不是很好) )...(我正在使用Slim btw)
我希望能够执行以下操作:= edit_button(路径,“可选的显示文本”,“可选的额外类”)
table.grid
thead
tr
th Researcher
th Email Address
th Last Activity
th Activated
th Failed logins
th Locked
th Actions
tbody
- @users.each do |user|
tr
td
= "#{user.first_name} #{user.last_name}"
td
= user.email
td
| About 1 day ago
td
| Yes
td
= user.failed_logins_count
td
| No
td
div.actions
a.small.button.edit href=edit_user_path(user)
i.general.foundicon-edit
| Edit
a.small.button.delete href=user_path(user) method='delete' data-confirm='Are you sure?'
i.general.foundicon-trash
| Delete
建议使用局部函数来干燥视图。 请参阅此页面的前几行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.