Browse Source

Use models to sort data when possible

eperez-timeinput
Jason Denney 11 years ago
parent
commit
ec5db646a0
  1. 1
      app/components/bikes.rb
  2. 1
      app/components/users.rb
  3. 2
      app/models/bike.rb
  4. 2
      app/models/user.rb

1
app/components/bikes.rb

@ -2,7 +2,6 @@ class Bikes < Netzke::Basepack::Grid
def configure(c) def configure(c)
super super
c.model = "Bike" c.model = "Bike"
c.data_store.sorters = [{ :property => :shop_id, :direction => :ASC}]
# columns with :id set, have :min_chars set in init_component # columns with :id set, have :min_chars set in init_component
# See: http://stackoverflow.com/questions/17738962/netzke-grid-filtering # See: http://stackoverflow.com/questions/17738962/netzke-grid-filtering

1
app/components/users.rb

@ -13,7 +13,6 @@ class Users < Netzke::Basepack::Grid
c.header = false c.header = false
c.model = "User" c.model = "User"
c.data_store.sorters = [{ :property => :username, :direction => :ASC}]
c.columns = [ c.columns = [
{ :name => :username, :read_only => true }, { :name => :username, :read_only => true },
:first_name, :first_name,

2
app/models/bike.rb

@ -12,6 +12,8 @@ class Bike < ActiveRecord::Base
belongs_to :bike_condition belongs_to :bike_condition
belongs_to :bike_purpose belongs_to :bike_purpose
default_scope order('shop_id ASC')
validates :shop_id, :presence => true, :uniqueness => true, :length => { :minimum => 3 } validates :shop_id, :presence => true, :uniqueness => true, :length => { :minimum => 3 }
validates :serial_number, :length => { :minimum => 3 } validates :serial_number, :length => { :minimum => 3 }
validates :model, :length => { :maximum => 50 } validates :model, :length => { :maximum => 50 }

2
app/models/user.rb

@ -20,6 +20,8 @@ class User < ActiveRecord::Base
belongs_to :bike belongs_to :bike
default_scope order('username ASC')
validates :first_name, :presence => true validates :first_name, :presence => true
validates :last_name, :presence => true validates :last_name, :presence => true

Loading…
Cancel
Save