Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

# 12 fixed ticket about empty association errors

  • Loading branch information...
commit e7763ece0f484d0e6095b1d2074cc891789f3be2 1 parent 46fe6f9
Jessy Bernal authored
View
11 app/controllers/rows_controller.rb
@@ -12,11 +12,14 @@ def index
redirect_to datab_table_path(@datab, @table)
return
end
-
rows = @table.ar_class.all :conditions => {params[:field] => params[:value]}
- @rows = WillPaginate::Collection.create(1, rows.size) do |pager|
- pager.replace rows
- pager.total_entries = rows.size
+ if rows.empty?
+ @rows = []
+ else
+ @rows = WillPaginate::Collection.create(1, rows.size) do |pager|
+ pager.replace rows
+ pager.total_entries = rows.size
+ end
end
end
View
7 app/views/rows/index.html.erb
@@ -1,6 +1,13 @@
<% @title = @table.name + " #{params[:field]} = " + params[:value] %>
+<% if @rows.empty? %>
+ <div class="notification">0 results found in <%= @table.name %> matching <%= params[:field] %> = <%= params[:value] %></div>
+<% else %>
+ <%= number_with_delimiter @rows.size %> records
+
<%= render :partial => "/tables/browse", :locals => {
:columns => @table.columns,
:rows => @rows
} %>
+
+<% end%>
View
23 test/functional/rows_controller_test.rb
@@ -1,4 +1,27 @@
require 'test_helper'
class RowsControllerTest < ActionController::TestCase
+
+ def setup
+ super
+ @request.session[:username] = @@config['user']
+ @request.session[:password] = @@config['password']
+ create_database 'rbdb_test1' do |datab|
+ datab.create_table 'databs' do |t|
+ t.string :field1, :limit => 1
+ t.integer :association_id, :null => false
+ t.boolean :test, :null => false, :default => false
+ end
+ datab.create_table 'associations' do |t|
+ t.string :name
+ end
+ end
+ end
+
+ should "display 0 result if no data found in association" do
+ get :index, :id => 'databs', :datab_id => 'rbdb_test1', :field=>'association_id', :value => '82533'
+ assert_response :success
+ end
+
+
end

0 comments on commit e7763ec

Please sign in to comment.
Something went wrong with that request. Please try again.