k-isabelle
5/31/2018 - 4:29 PM

Ruby Guides

Ruby Guides

Adding fields to an object

  1. Document it in object model, in the #structure do block eg: models/effective/User.rb
  2. Create a database migration for the fields - run command such as: rails generate migration add_fields_to_users participant:string how_did_you_hear:string and it will generate the file for you (migrations appear in db/migrate/12345_add_fields_to_users.rb)
  3. Run rake db:migrate

http://edgeguides.rubyonrails.org/active_record_migrations.html

Adding a View to Prototype

  1. in routes.rb, change the team dashboard to be only: [:index]
  2. in team dashboard controller, add the index action just like the show action
  3. also in team dashboard controller add skip_authorization_check # CanCanCan to the top of the page to bypass user authorization
  4. then create /app/views/team_dashboard/index.html.haml
  5. then visit /team_dashboard

Add a New Page

  1. update routes.rb with the invitations resource, nested in a users namespace (similar to admin).
  2. create /app/controllers/users/invitations_controller.rb
  3. create /app/views/users/invitations/new.html.haml

Adding a Datatable

  1. Create datatable in models/effective/datatables, eg. models/effective/datatables/users.rb
  2. Define datatable constant in controller, eg. controllers/admin/users_controller.rb : @datatable = Effective::Datatables::Users.new
  3. Render the datatable in your view = render_datatable(@datatable)

Simple Form

= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|

You can also view online:

http://espcn-prototype.herokuapp.com User: espcn Pass: prototype

http://scip-prototype.herokuapp.com/ User: scip Pass: prototype