For instance, in the table below, I am using the actions over and over throughout my app, and I am not quite sure how to DRY it up, either partial views or rails helpers (which don't seem great for dealing with html fragments)...(I am using Slim btw)
I would like to be able to do something like: = edit_button (path, 'optional display text', 'optional extra classes)
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
Using partials are the rails recommended way to DRY up your view. See the first few lines of this page.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.