『エンタープライズRails』に学ぶ企業ユーザのためのRailsアーキテクチャ

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    5 Favorites & 1 Event

    『エンタープライズRails』に学ぶ企業ユーザのためのRailsアーキテクチャ - Presentation Transcript

    1. 80 60 40 20 0 2007 2008 2009
    2. Po w ere d by vs
    3. class Employee < ActiveRecord::Base validates_presence_of :name CREATE TABLE employees ( name VARCHAR(40) NOT NULL,
    4. class Employee < ActiveRecord::Base validates_length_of :login, :minimum => 5 CREATE TABLE employees ( login VARCHAR(10) check(length(login) > 4),
    5. begin emp = Employee.new(:login => '') emp.save_with_validation(false) fail rescue ActveRecord::StatementInvalid end
    6. Departments Employees
    7. class Employee < ActiveRecord::Base belongs_to :department validates_presence_of :department CREATE TABLE employees ( department_id INTEGER NOT NULL REFERENCES departments(id),
    8. Companies Departments Employees
    9. has_many :though company.employees.size SELECT count(*) AS count_all FROM employees INNER JOIN departments ON employees.department_id = departments.id WHERE departments.company_id = 1
    10. SELECT count(*) AS count_all FROM employees WHERE company_id = 1 Companies ? Departments Employees
    11. company_id department_id Companies Departments Employees id id id company_id company_id department_id
    12. Companies Departments Employees id company_id id department_id company_id department_id
    13. departments CREATE TABLE departments( company_id INTEGER NOT NULL REFERENCES companies(id), department_id SERIAL NOT NULL, PRIMARY KEY (company_id, department_id)
    14. employees CREATE TABLE employees( company_id INTEGER NOT NULL REFERENCES companies(id), department_id INTEGER NOT NULL, FOREIGN KEY (company_id, department_id) REFERENCES department (company_id, department_id)
    15. departments company_id department_id employees Companies Departments Employees id company_id id department_id company_id department_id
    16. # gem install composite_primary_keys
    17. Department class Department < ActiveRecord::Base set_primary_keys :company_id, :department_id has_many :employees, :foreign_keys => [:company_id, :department_id]
    18. Company class Company < ActiveRecord::Base def employees_size Employee.count( :conditions => ['company_id = ?', id]) end
    19. CREATE VIEW big_campanies AS SELECT * FROM companies WHERE id IN (SELECT company_id FROM (SELECT compay_id, count(id) AS c FROM employees GROUP BY company_id) AS t WEHRE c > 1000)
    20. BigCampany class BigCampany < ActiveRecord::Base has_many :department end
    21. SELECT * FROM (SELCT * FROM ...)
    SlideShare Zeitgeist 2009

    + Naoto TakaiNaoto Takai Nominate

    custom

    1793 views, 5 favs, 4 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1793
      • 1594 on SlideShare
      • 199 from embeds
    • Comments 0
    • Favorites 5
    • Downloads 40
    Most viewed embeds
    • 193 views on http://recompile.net
    • 4 views on http://www2.neasf.co.jp
    • 1 views on http://fieldnotes.sytes.net
    • 1 views on https://www2.neasf.co.jp

    more

    All embeds
    • 193 views on http://recompile.net
    • 4 views on http://www2.neasf.co.jp
    • 1 views on http://fieldnotes.sytes.net
    • 1 views on https://www2.neasf.co.jp

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Groups / Events