Корпоративное приложение на Rails

  • Published on
    02-Jul-2015

  • View
    182

  • Download
    0

Embed Size (px)

DESCRIPTION

, Rails .

Transcript

  • 1. Rails. @ka8725

2. (sidekiq) Rails engines 3. 4. ? , Rails 5. Ruby modules Rails engines 6. Ruby modules , Ruby DataGrid - client admin Draper - InheritedResources - (AR ) Rails - polymorphic routes helper- 7. Rails Engines gems Ruby . , Rails Engines - rake railties:install:migrations Rails Engine . 8. 9. Pull request , Ruby Pub-Sub, ActiveSupport::Notifications- - 10. Pub-Sub# CorePublisher.broadcast_event('user.created', {user_id: 1})!# PluginSubscriber.subscribe('user.created') do |event|payload = event.payloadputs payload[:user_id]endhttp://goo.gl/QJxujy 11. Pub-Sub . 12. - Rails engine 13. Railsengines . View, Routes,Controllers, Models, Helpers ( ) 14. ActiveRecord nested_attributes FormObjects, ServiceObjects,QueryObjects, PolicyObjects , Observers Callbacks 15. callbacks 16. Observers callbacks callbacks 17. ? 18. c ! , ! 19. class ActiveRecord::Basecattr_accessor :skip_callbacks-end!class User < ActiveRecord::Baseafter_create :send_invitation, unless: :skip_callbacksdef send_invitationputs 'hello'endend!ActiveRecord::Base.skip_callbacks = trueUser.create # =>ActiveRecord::Base.skip_callbacks = falseUser.create # => 'hello' 20. View helper- instance (@var) view fields_for nested_attributes AngularJS 21. helper-plugin_exchange_client_account_application_contact_contact_distribution_group_path(parent.account,parent.core_application, parent, resource)! 141 ! 22. # Controllersclass SomeController < ApplicationControllerhelper_method :submit_pathhelper_method :cancel_path!private!def submit_pathany_size_of_helper_method_you_want_submit_path(arg1,arg2,)end!def cancel_pathany_size_of_helper_method_you_want_cancel_path(arg1,arg2,)end!end 23. # Views!= form_tag submit_path do= link_to 'Cancel', cancel_path 24. , view HAML !PS. HAML! - SLIM. 25. Helper- @var (undefinedmethod my_helper_method undefined_method for nil class) 26. DataGrid- ( scopes) view 3 (!!!) - https://github.com/bogdan/datagrid 27. fields_for nested_attributes FormObjects nested_attributes primary key . id, rails 28. fields_for nested_attributes- form_object.locations.each do |location|= f.fields_for 'locations[]', location, include_id: false,index: nil do |ff|# include_id: false - hidden field c id, .. # index: nil - index 29. primary FormObjects 30. AngularJS .. ng-init input ng-model ng-init , ng-model, ?Reload ? - flash 31. Rails? 32. Rails way Enterprise way 33. Rails - Rails Rails- . , (SOLID) 34. Ruby ? DSL :( 35. Enterprise Rails? Rails? , Sinatra + Grape, SPA (Single Page Application)? . Use Cases- UseCases ( ). ActiveRecord. ActiveRecord - ! . 100500 InheritedResources, . SOLID, 36. 1. http://goo.gl/GyqjXg - 7 steps to get started with CleanArchitecture in Ruby2. http://goo.gl/g0VA1 - 7 Patterns to Refactor Fat ActiveRecordModels3. http://goo.gl/lz1fEX - Ruby Midwest 2011 - Keynote: Architecturethe Lost Years by Robert Martin4. http://goo.gl/MP6L7Z - High-Low Testing5. http://goo.gl/aI3kdc - Growing Rails Applications in Practice6. http://goo.gl/9KsmM - (S.O.L.I.D.) 37. ! Rake -Thor 38. ? @ka8725-ka8725@gmail.com