Skip to content

Commit

Permalink
Sorting by state order, unelegantly.
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipoertel committed Oct 16, 2011
1 parent 05acd90 commit 78a577e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/controllers/flats_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def create

if @flat.save
flash[:created_flat_id] = @flat.id
redirect_to flats_path, :notice => 'Flat was successfully created.'
redirect_to flats_path, :notice => 'Flat created.'
else
flash[:error] = @flat.errors
render :action => "new"
Expand All @@ -52,7 +52,7 @@ def update

respond_to do |format|
if @flat.update_attributes(params[:flat])
flash[:notice] = 'flat was successfully updated.'
flash[:notice] = 'Flat updated.'
format.html { redirect_to(flats_path) }
format.xml { head :ok }
else
Expand Down
6 changes: 4 additions & 2 deletions app/views/flats/_flats_list.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#flats-list
- @flats.group_by(&:state).each do |state, flats|
= render :partial => "flats_table", :locals => { :flats => flats, :state => state, :show_phone => false }
- Flat::STATES.each do |state|
- flats = @flats.select { |flat| flat.state == state }
- unless flats.empty?
= render :partial => "flats_table", :locals => { :flats => flats, :show_phone => false }

2 changes: 1 addition & 1 deletion app/views/flats/_flats_table.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%table.flats
%tr
%th.state
%h2= state.humanize
%h2= flats.first.state.humanize
%th
%th
%th.rooms rooms
Expand Down

0 comments on commit 78a577e

Please sign in to comment.