mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
Use Rails helpers for the edit button
Instead of creating id and routes manually, use the helpers that Rails provides in order to do this for us.
This commit is contained in:
parent
e39177b82d
commit
3bef4daacc
2 changed files with 13 additions and 3 deletions
|
|
@ -154,10 +154,10 @@ module TodosHelper
|
|||
|
||||
def remote_edit_button(todo=@todo)
|
||||
link_to(
|
||||
image_tag("blank.png", :alt => t('todos.edit'), :align => "absmiddle", :id => 'edit_icon_todo_'+todo.id.to_s, :class => 'edit_item'),
|
||||
{:controller => 'todos', :action => 'edit', :id => todo.id},
|
||||
image_tag("blank.png", :alt => t('todos.edit'), :align => "absmiddle", :id => dom_id(todo, "edit_icon"), :class => 'edit_item'),
|
||||
edit_todo_path(todo),
|
||||
:class => "icon edit_item",
|
||||
:id => "icon_edit_todo_#{todo.id}",
|
||||
:id => dom_id(todo, "icon_edit"),
|
||||
:title => t('todos.edit_action_with_description', :description => todo.description))
|
||||
end
|
||||
|
||||
|
|
|
|||
10
test/helpers/todo_helpers_test.rb
Normal file
10
test/helpers/todo_helpers_test.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
require "test_helper"
|
||||
|
||||
class TodosHelpersTest < ActionView::TestCase
|
||||
include TodosHelper
|
||||
|
||||
test "remote_edit_button" do
|
||||
html = remote_edit_button(todos(:call_bill))
|
||||
assert_equal "<a class=\"icon edit_item\" href=\"/todos/1/edit\" id=\"icon_edit_todo_1\" title=\"Edit the action 'Call Bill Gates to find out how much he makes per day'\"><img align=\"absmiddle\" alt=\"Edit\" class=\"edit_item\" id=\"edit_icon_todo_1\" src=\"/images/blank.png\" /></a>", html
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue