SlideShare ist ein Scribd-Unternehmen logo
1 von 10
Downloaden Sie, um offline zu lesen
RoR – Rails 2


    ●   Миграции
    ●   Валидация
    ●   Контроллер
    ●   Отображение
    ●   Partial



                       
Rake таски
    ●   rake db:migrate
    ●   rake db:migrate:rollback
    ●   rake db:migrate:redo
    ●   rake db:migrate:rollback STEP=3
    ●   rake db:migrate:redo STEP=3
    ●   rake db:migrate:up VERSION=xxxxxxxxxxxxx
    ●   rake db:migrate:down VERSION=xxxxxxxxxxxx

                                
Работа с таблицами
    ●   Операции с таблицами
          create_table, drop_table, change_table

    ●   Операции с колонками:
          add_column, change_column,  change_column_default, 
          rename_column,  remove_column,  add_index,  
          remove_index

    ●   Типы полей:
          :primary_key, :string, :text, :integer, :float, :decimal, 
          :datetime, :timestamp, :time, :date, :binary, :boolean
                                       
Связи между моделями

    ●   belongs_to
    ●   has_one
    ●   has_many
    ●   has_many :through
    ●   has_one :through
    ●   has_and_belongs_to_many



                             
Валидации
    ●   Валидации проверяются при вызове:
        create, create!, save, save!, update, update_attributes, 
        update_attributes!
    ●   Не проверяются для: 
        decrement!, decrement_counter, increment!, 
        increment_counter, toggle!, update_all, update_attribute, 
        update_counters
    ●   Проверка валидности объекта:
         valid? and invalid?
    ●   Получить массив ошибок
        entity.errors[:attribute]

                                     
Хелперы
    ●   validates_acceptance_of
    ●   validates_associated
    ●   validates_confirmation_of
        <%= text_field :person, :email %>
        <%= text_field :person, :email_confirmation %>
    ●   validates_exclusion_of, validates_inclusion_of
        validates_exclusion_of :field, :in => [values], :message => 
        'message'
    ●   validates_format_of
        validates_format_of :field, :with => /Regexp/,
        :message => "message"

                                     
Хелперы

    ●   validates_length_of 
        :minimum, :maximum, :in, :is
    ●   validates_numericality_of (:only_integer => true)
    ●   validates_uniqueness_of (:scope => :attribute)
    ●   validate :validate_method
        def validate_method
        end
    ●   пр.


                                  
Callbacks

    ●   before_validation
    ●   after_validation
    ●   before_save
    ●   after_save
    ●   before_update
    ●   around_update
    ●   after_update
    ●   before_destroy
    ●   after_destroy
    ●   around_destroy
    ●   around_destroy
                             
Котроллеры → фильтры



    ●   before_filter
    ●   after_filter
    ●   around_filter




                         
Controller → response
    ●   render
    ●   redirect_to to
    ●   head




                          

Weitere ähnliche Inhalte

Andere mochten auch

A republic of science
A republic of scienceA republic of science
A republic of sciencetuya0625
 
Year 12 as media coursework evaluation
Year 12 as media  coursework evaluationYear 12 as media  coursework evaluation
Year 12 as media coursework evaluationJamieSansom10
 
Seasonsweather
SeasonsweatherSeasonsweather
Seasonsweathertuya0625
 
A republic of science for lesson
A republic of science for lessonA republic of science for lesson
A republic of science for lessontuya0625
 
Richard wright
Richard wrightRichard wright
Richard wrighttuya0625
 
Green world
Green worldGreen world
Green worldtuya0625
 

Andere mochten auch (14)

A republic of science
A republic of scienceA republic of science
A republic of science
 
Year 12 as media coursework evaluation
Year 12 as media  coursework evaluationYear 12 as media  coursework evaluation
Year 12 as media coursework evaluation
 
Bbbb
BbbbBbbb
Bbbb
 
Seasonsweather
SeasonsweatherSeasonsweather
Seasonsweather
 
A republic of science for lesson
A republic of science for lessonA republic of science for lesson
A republic of science for lesson
 
Richard wright
Richard wrightRichard wright
Richard wright
 
Green world
Green worldGreen world
Green world
 
Homonym
HomonymHomonym
Homonym
 
Ilhan sürül
Ilhan sürülIlhan sürül
Ilhan sürül
 
Ilhan sürül
Ilhan sürülIlhan sürül
Ilhan sürül
 
Ilhan sürül
Ilhan sürülIlhan sürül
Ilhan sürül
 
Bbbb
BbbbBbbb
Bbbb
 
Ilhan sürül
Ilhan sürülIlhan sürül
Ilhan sürül
 
Bbbb
BbbbBbbb
Bbbb
 

Ähnlich wie Ror rails 2

ruby on rails pitfalls
ruby on rails pitfallsruby on rails pitfalls
ruby on rails pitfallsRobbin Fan
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialYi-Ting Cheng
 
Ruby On Rails Pitfalls
Ruby On Rails PitfallsRuby On Rails Pitfalls
Ruby On Rails PitfallsRobin Lu
 
More to RoC weibo
More to RoC weiboMore to RoC weibo
More to RoC weiboshaokun
 
ActiveRecord Validations, Season 2
ActiveRecord Validations, Season 2ActiveRecord Validations, Season 2
ActiveRecord Validations, Season 2RORLAB
 
Building Better Applications with Data::Manager
Building Better Applications with Data::ManagerBuilding Better Applications with Data::Manager
Building Better Applications with Data::ManagerJay Shirley
 
Staying railsy - while scaling complexity or Ruby on Rails in Enterprise Soft...
Staying railsy - while scaling complexity or Ruby on Rails in Enterprise Soft...Staying railsy - while scaling complexity or Ruby on Rails in Enterprise Soft...
Staying railsy - while scaling complexity or Ruby on Rails in Enterprise Soft...Coupa Software
 
Rails antipattern-public
Rails antipattern-publicRails antipattern-public
Rails antipattern-publicChul Ju Hong
 
Rails antipatterns
Rails antipatternsRails antipatterns
Rails antipatternsChul Ju Hong
 
devise tutorial - 2011 rubyconf taiwan
devise tutorial - 2011 rubyconf taiwandevise tutorial - 2011 rubyconf taiwan
devise tutorial - 2011 rubyconf taiwanTse-Ching Ho
 
Damage Control
Damage ControlDamage Control
Damage Controlsintaxi
 
Let it crash - fault tolerance in Elixir/OTP
Let it crash - fault tolerance in Elixir/OTPLet it crash - fault tolerance in Elixir/OTP
Let it crash - fault tolerance in Elixir/OTPMaciej Kaszubowski
 
Floripa on Rails - dev workflow
Floripa on Rails - dev workflowFloripa on Rails - dev workflow
Floripa on Rails - dev workflowJônatas Paganini
 
Buytaert kris tools
Buytaert kris toolsBuytaert kris tools
Buytaert kris toolskuchinskaya
 
Ruby on rails
Ruby on rails Ruby on rails
Ruby on rails Mohit Jain
 
Rails2 Pr
Rails2 PrRails2 Pr
Rails2 Prxibbar
 
7 tools for your devops stack
7 tools for your devops stack7 tools for your devops stack
7 tools for your devops stackKris Buytaert
 

Ähnlich wie Ror rails 2 (20)

ruby on rails pitfalls
ruby on rails pitfallsruby on rails pitfalls
ruby on rails pitfalls
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
 
Ruby On Rails Pitfalls
Ruby On Rails PitfallsRuby On Rails Pitfalls
Ruby On Rails Pitfalls
 
Introduction to Angular JS
Introduction to Angular JSIntroduction to Angular JS
Introduction to Angular JS
 
More to RoC weibo
More to RoC weiboMore to RoC weibo
More to RoC weibo
 
ActiveRecord Validations, Season 2
ActiveRecord Validations, Season 2ActiveRecord Validations, Season 2
ActiveRecord Validations, Season 2
 
Building Better Applications with Data::Manager
Building Better Applications with Data::ManagerBuilding Better Applications with Data::Manager
Building Better Applications with Data::Manager
 
Staying railsy - while scaling complexity or Ruby on Rails in Enterprise Soft...
Staying railsy - while scaling complexity or Ruby on Rails in Enterprise Soft...Staying railsy - while scaling complexity or Ruby on Rails in Enterprise Soft...
Staying railsy - while scaling complexity or Ruby on Rails in Enterprise Soft...
 
Rails antipattern-public
Rails antipattern-publicRails antipattern-public
Rails antipattern-public
 
Rails antipatterns
Rails antipatternsRails antipatterns
Rails antipatterns
 
devise tutorial - 2011 rubyconf taiwan
devise tutorial - 2011 rubyconf taiwandevise tutorial - 2011 rubyconf taiwan
devise tutorial - 2011 rubyconf taiwan
 
Damage Control
Damage ControlDamage Control
Damage Control
 
Let it crash - fault tolerance in Elixir/OTP
Let it crash - fault tolerance in Elixir/OTPLet it crash - fault tolerance in Elixir/OTP
Let it crash - fault tolerance in Elixir/OTP
 
Floripa on Rails - dev workflow
Floripa on Rails - dev workflowFloripa on Rails - dev workflow
Floripa on Rails - dev workflow
 
Buytaert kris tools
Buytaert kris toolsBuytaert kris tools
Buytaert kris tools
 
Ruby on rails
Ruby on rails Ruby on rails
Ruby on rails
 
TDD, BDD and mocks
TDD, BDD and mocksTDD, BDD and mocks
TDD, BDD and mocks
 
Rails2 Pr
Rails2 PrRails2 Pr
Rails2 Pr
 
Code Management
Code ManagementCode Management
Code Management
 
7 tools for your devops stack
7 tools for your devops stack7 tools for your devops stack
7 tools for your devops stack
 

Ror rails 2

  • 1. RoR – Rails 2 ● Миграции ● Валидация ● Контроллер ● Отображение ● Partial    
  • 2. Rake таски ● rake db:migrate ● rake db:migrate:rollback ● rake db:migrate:redo ● rake db:migrate:rollback STEP=3 ● rake db:migrate:redo STEP=3 ● rake db:migrate:up VERSION=xxxxxxxxxxxxx ● rake db:migrate:down VERSION=xxxxxxxxxxxx    
  • 3. Работа с таблицами ● Операции с таблицами create_table, drop_table, change_table ● Операции с колонками: add_column, change_column,  change_column_default,  rename_column,  remove_column,  add_index,   remove_index ● Типы полей: :primary_key, :string, :text, :integer, :float, :decimal,  :datetime, :timestamp, :time, :date, :binary, :boolean    
  • 4. Связи между моделями ● belongs_to ● has_one ● has_many ● has_many :through ● has_one :through ● has_and_belongs_to_many    
  • 5. Валидации ● Валидации проверяются при вызове: create, create!, save, save!, update, update_attributes,  update_attributes! ● Не проверяются для:  decrement!, decrement_counter, increment!,  increment_counter, toggle!, update_all, update_attribute,  update_counters ● Проверка валидности объекта:  valid? and invalid? ● Получить массив ошибок entity.errors[:attribute]    
  • 6. Хелперы ● validates_acceptance_of ● validates_associated ● validates_confirmation_of <%= text_field :person, :email %> <%= text_field :person, :email_confirmation %> ● validates_exclusion_of, validates_inclusion_of validates_exclusion_of :field, :in => [values], :message =>  'message' ● validates_format_of validates_format_of :field, :with => /Regexp/, :message => "message"    
  • 7. Хелперы ● validates_length_of  :minimum, :maximum, :in, :is ● validates_numericality_of (:only_integer => true) ● validates_uniqueness_of (:scope => :attribute) ● validate :validate_method def validate_method end ● пр.    
  • 8. Callbacks ● before_validation ● after_validation ● before_save ● after_save ● before_update ● around_update ● after_update ● before_destroy ● after_destroy ● around_destroy ● around_destroy    
  • 9. Котроллеры → фильтры ● before_filter ● after_filter ● around_filter    
  • 10. Controller → response ● render ● redirect_to to ● head