0

I've got some database in .yml format and i don't understand what's scaffold and models i need to cr8 for this app. .yml file:

users:
 - group: 'Admin'
   todo_list:
    - text: 'Create new user group'
      isCompleted: false
 - group: 'Moderator'
   todo_list:
    - text: 'Ban 2 or more users'
      isCompleted: false
 - group: 'User'
   todo_list:
    - text: 'create someone stupid question like this'
      isCompleted: false
Nikolay Vetrov
  • 624
  • 6
  • 17

1 Answers1

0

ok so this is what you will want to do:

rails g scaffold user toDo:text isComplete:boolean 

rails g scaffold moderator toDo:text isComplete:boolean 

rails g scaffold admin toDo:text isComplete:boolean 

the scaffold command will generate all your templates for each item and give you a standard rails display for your CRUD Action

Each scaffold will create a model for each user type Admin, Moderator and User, it will also generate your controllers with basic functionality

once you have completed the scaffold generate you can go into app/db/migrations open them up and use :default => false to set the default value of the boolean (checkbox)

So your migration file should look like:

class AddUsers
  def up
    t.boolean :users, :isComplete, :default => true
  end
end

class AddModerators
  def up
    t.boolean :moderators, :isComplete, :default => true
  end
end

class AddAdmins
  def up
    t.boolean :admins, :isComplete, :default => true
  end
end

Hope this helps

Shawn Wilson
  • 1,311
  • 14
  • 40
  • thanks for your answer, but it's actually like to do list, not user authorizations. – Nikolay Vetrov Jul 14 '16 at 16:23
  • ok so do the user groups all have access to the same items on the list? im just confused about how this is supposed to be laid out. – Shawn Wilson Jul 14 '16 at 16:24
  • it's just i've got 3 groups of users, and in each of this groups - to do list. I don't need to cr8 new users group, but i need to cr8 new task for 1 of this groups (admin, moderator, user); Looks like: {Admin *task1; *task2; ... Moderator: *task1; *task2; ... User: *task1; *task2; ...} – Nikolay Vetrov Jul 14 '16 at 16:35
  • Answer has been updated to reflect your comment description – Shawn Wilson Jul 14 '16 at 16:49