Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# The models Let's review what we want this app to do: * Track multiple projects * Each having a collection of stories * Stories are just a brief chunk of text * A story can be assigned a current status and a set of outstanding tasks * Tasks can be assigned to users * Users can get an easy heads up of the tasks they are assigned to Sounds to me like we just sketched a first-cut of our models. We'll start with: * `Project` (with a name) has many stories * `Story` (with a title, description and status) belongs to a project has many tasks * `Task` (with a description) belongs to a story has many users (through task-assignments) * `User` (we'll stick with the standard fields provided by Hobo) has many tasks (through task-assignments) Hopefully the connection between the goal and those models is clear. If not, you'll probably find it gets easier once you've done it a few times. Before long you'll be throwing models into your app without even stopping to write the names down. Of course -- chances are you've got something wrong, made a bad decision. So? Just throw them away and create some new ones when the time comes. We're sketching here! Here's how we create these with a Hobo generator: $ ./script/generate hobo_model_resource project name:string $ ./script/generate hobo_model_resource story title:string body:text status:string $ ./script/generate hobo_model_resource task description:string Task assignments are just a back-end model. They don't need a controller, so: $ ./script/generate hobo_model task_assignment
- Loading branch information
1 parent
d15ee01
commit 67831c7
Showing
25 changed files
with
252 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ProjectsController < ApplicationController | ||
|
||
hobo_model_controller | ||
|
||
auto_actions :all | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class StoriesController < ApplicationController | ||
|
||
hobo_model_controller | ||
|
||
auto_actions :all | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class TasksController < ApplicationController | ||
|
||
hobo_model_controller | ||
|
||
auto_actions :all | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module ProjectsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module StoriesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module TasksHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class Project < ActiveRecord::Base | ||
|
||
hobo_model # Don't put anything above this | ||
|
||
fields do | ||
name :string | ||
timestamps | ||
end | ||
|
||
|
||
# --- Permissions --- # | ||
|
||
def create_permitted? | ||
acting_user.administrator? | ||
end | ||
|
||
def update_permitted? | ||
acting_user.administrator? | ||
end | ||
|
||
def destroy_permitted? | ||
acting_user.administrator? | ||
end | ||
|
||
def view_permitted?(field) | ||
true | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class Story < ActiveRecord::Base | ||
|
||
hobo_model # Don't put anything above this | ||
|
||
fields do | ||
title :string | ||
body :text | ||
status :string | ||
timestamps | ||
end | ||
|
||
|
||
# --- Permissions --- # | ||
|
||
def create_permitted? | ||
acting_user.administrator? | ||
end | ||
|
||
def update_permitted? | ||
acting_user.administrator? | ||
end | ||
|
||
def destroy_permitted? | ||
acting_user.administrator? | ||
end | ||
|
||
def view_permitted?(field) | ||
true | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class Task < ActiveRecord::Base | ||
|
||
hobo_model # Don't put anything above this | ||
|
||
fields do | ||
description :string | ||
timestamps | ||
end | ||
|
||
|
||
# --- Permissions --- # | ||
|
||
def create_permitted? | ||
acting_user.administrator? | ||
end | ||
|
||
def update_permitted? | ||
acting_user.administrator? | ||
end | ||
|
||
def destroy_permitted? | ||
acting_user.administrator? | ||
end | ||
|
||
def view_permitted?(field) | ||
true | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class TaskAssignment < ActiveRecord::Base | ||
|
||
hobo_model # Don't put anything above this | ||
|
||
fields do | ||
timestamps | ||
end | ||
|
||
|
||
# --- Permissions --- # | ||
|
||
def create_permitted? | ||
acting_user.administrator? | ||
end | ||
|
||
def update_permitted? | ||
acting_user.administrator? | ||
end | ||
|
||
def destroy_permitted? | ||
acting_user.administrator? | ||
end | ||
|
||
def view_permitted?(field) | ||
true | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ProjectHints < Hobo::ViewHints | ||
|
||
# model_name "My Model" | ||
# field_names :field1 => "First Field", :field2 => "Second Field" | ||
# field_help :field1 => "Enter what you want in this field" | ||
# children :primary_collection1, :aside_collection1, :aside_collection2 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class StoryHints < Hobo::ViewHints | ||
|
||
# model_name "My Model" | ||
# field_names :field1 => "First Field", :field2 => "Second Field" | ||
# field_help :field1 => "Enter what you want in this field" | ||
# children :primary_collection1, :aside_collection1, :aside_collection2 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class TaskAssignmentHints < Hobo::ViewHints | ||
|
||
# model_name "My Model" | ||
# field_names :field1 => "First Field", :field2 => "Second Field" | ||
# field_help :field1 => "Enter what you want in this field" | ||
# children :primary_collection1, :aside_collection1, :aside_collection2 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class TaskHints < Hobo::ViewHints | ||
|
||
# model_name "My Model" | ||
# field_names :field1 => "First Field", :field2 => "Second Field" | ||
# field_help :field1 => "Enter what you want in this field" | ||
# children :primary_collection1, :aside_collection1, :aside_collection2 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
one: | ||
id: 1 | ||
|
||
two: | ||
id: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
one: | ||
id: 1 | ||
|
||
two: | ||
id: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
one: | ||
id: 1 | ||
|
||
two: | ||
id: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
one: | ||
id: 1 | ||
|
||
two: | ||
id: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
class ProjectsControllerTest < ActionController::TestCase | ||
# Replace this with your real tests. | ||
def test_truth | ||
assert true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
class StoriesControllerTest < ActionController::TestCase | ||
# Replace this with your real tests. | ||
def test_truth | ||
assert true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
class TasksControllerTest < ActionController::TestCase | ||
# Replace this with your real tests. | ||
def test_truth | ||
assert true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
class ProjectTest < ActiveSupport::TestCase | ||
# Replace this with your real tests. | ||
def test_truth | ||
assert true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
class StoryTest < ActiveSupport::TestCase | ||
# Replace this with your real tests. | ||
def test_truth | ||
assert true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
class TaskAssignmentTest < ActiveSupport::TestCase | ||
# Replace this with your real tests. | ||
def test_truth | ||
assert true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
class TaskTest < ActiveSupport::TestCase | ||
# Replace this with your real tests. | ||
def test_truth | ||
assert true | ||
end | ||
end |