small improvements

render :partial => filename, :object => @object can be written shorter since rails 2.0 like
render :partial => @object or render :partial => @collection
Also form_for is smart bout put and post for update and creation.

it helps watching older railcasts episodes :-)
This commit is contained in:
Reinier Balt 2010-11-29 11:04:15 +01:00
parent edb3668dba
commit 484356fe07
15 changed files with 51 additions and 52 deletions

View file

@ -1,7 +1,7 @@
<div class="container" id="note-<%= note.id %>-wrapper">
<div id="<%= dom_id(note, 'container') %>">
<h2><%= link_to(t('notes.note_header', :id => note.id.to_s), note_path(note), :title => t('notes.note_link_title', :id => note.id.to_s)) %></h2>
<h2><%= link_to(t('notes.note_header', :id => note.id.to_s), note, :title => t('notes.note_link_title', :id => note.id.to_s)) %></h2>
<div class="project_notes" id="<%= dom_id(note) %>">
<%= render :partial => "notes/note_details", :object => note %>

View file

@ -6,7 +6,7 @@
<%= link_to_delete_note(note, image_tag( "blank.png",:title => t('notes.delete_item_title'), :class=>"delete_item")) %> &nbsp;
<%= link_to_edit_note(note, image_tag( "blank.png", :title => t('notes.edit_item_title'), :class=>"edit_item") ) %>
| <%= link_to("In: " + note.project.name, project_path(note.project), :class=>"footer_link" ) %>&nbsp;|&nbsp;
| <%= link_to("In: " + note.project.name, note.project, :class=>"footer_link" ) %>&nbsp;|&nbsp;
<%= Note.human_attribute_name('created_at') %>: <%= format_date(note.created_at) %>

View file

@ -1,12 +1,9 @@
<%
submit_text ||= t('common.update')
# :put for edit note and :post for new note
form_method ||= :put
form_for(note_edit_form, :html => {
:id => dom_id(note_edit_form, 'edit_form'),
:class => "inline-form edit-note-form",
:method => form_method }) do |f|
:class => "inline-form edit-note-form"}) do |f|
-%>
<div id="error_status"><%= error_messages_for("note") %></div>

View file

@ -2,7 +2,7 @@
<div class="note_wrapper" id="<%= dom_id(note) %>">
<%= link_to(
image_tag("blank.png", :border => 0),
note_path(note),
note,
:title => t('notes.show_note_title'),
:class => "link_to_notes icon",
:id => dom_id(note, "link")) %>&nbsp;

View file

@ -2,6 +2,6 @@
<% if @all_notes.empty? -%>
<div class="message"><p><%= t('notes.no_notes_available') %></p></div>
<% else -%>
<%= render :partial => 'note', :collection => @all_notes %>
<%= render :partial => @all_notes %>
<% end -%>
</div>

View file

@ -1,3 +1,3 @@
<div id="display_box_projects">
<%= render :partial => 'note', :object => @note %>
<%= render :partial => @note %>
</div>