Guest User

Untitled

a guest
Jun 14th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. # controller
  2. def create
  3. @bookmark = Bookmark.new(params[:bookmark])
  4. if @bookmark.save
  5. respond_to do |format|
  6. format.html do
  7. flash[:notice] = "Favorit wurde erfolgreich angelegt."
  8. redirect_to bookmarks_path
  9. end
  10. format.js do
  11. render :update do |page|
  12. page.insert_html :bottom, 'bookmarks', :partial => 'bookmark'
  13. end
  14.  
  15. end
  16.  
  17. end
  18. else
  19. render :action => "new"
  20. end
  21. end
  22.  
  23. # index
  24. <ul id="bookmarks">
  25. <%= render :partial => 'bookmark' %>
  26. </ul>
  27.  
  28. # partial
  29. <% @bookmarks.each do |bookmark|%>
  30. <li id="bookmark-<%= bookmark.id %>">
  31. <%= link_to h(bookmark.title), h(bookmark.url) %>
  32.  
  33. (<%= link_to "Details", bookmark_path(bookmark.id) %>
  34. <% if admin? %>
  35. |
  36. <%= link_to "ändern", edit_bookmark_path(bookmark.id) %> |
  37. <%= link_to "löschen", bookmark_path(bookmark),
  38. :method => :delete,
  39. :confirm => "Wollen Sie diesen Datensatz wirklich löschen?" %>
  40. <% end %>
  41. )
  42. </li>
  43. <% end %>
Add Comment
Please, Sign In to add comment