location_status enums
Mirv opened this issue · 3 comments
Mirv commented
- model constants w/values
- add to view edit
- add to view index
- add to view show
- view translation to string
- db entry
Mirv commented
- Add default value to db
change_column :users, :admin, :boolean, :default => false
Mirv commented
/app/models/location.rb
validates_presence_of :status
has_many :pets
/test/models/location_test.rb
test "invalid without status" do
@location.status = nil
refute @location.valid?
end
/app/views/locations/_form.html.haml
= f.label "Pet Status"
= f.select :status, Pet.statuses.keys.map { |w| [w.humanize, w] }
/app/views/locations/index.html.haml
%td= location.status.titleize
/app/views/pets/show.html.haml
%p
%b Pet Status:
= @pet.status.titleize
Mirv commented
Commit #805e32fd43d54c95609c74c87e94b876fb05a76e