1 / 22

Chapter 4.1 – Deeper into Rails

Chapter 4.1 – Deeper into Rails. Deeper into Rails. Presented b y :. Maciej Mensfeld. senior ruby developer@furioustribe.com. maciej@mensfeld.pl mensfeld.pl github.com / mensfeld. Maciej Mensfeld. Chapter 4.1 – Deeper into Rails. Deeper into Rails. Please ….

tanith
Download Presentation

Chapter 4.1 – Deeper into Rails

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 4.1 – DeeperintoRails DeeperintoRails Presented by: Maciej Mensfeld senior rubydeveloper@furioustribe.com maciej@mensfeld.pl mensfeld.pl github.com/mensfeld Maciej Mensfeld

  2. Chapter 4.1 – DeeperintoRails DeeperintoRails Please… • …ask me to slow down, if I speak to quickly; • …ask me again, if I forget; • …askquestions, ifanything i sayis not clear; • …feelfree to shareyourownobservations Maciej Mensfeld

  3. Chapter 4.1 – DeeperintoRails I18n – we speakdifferentlanguages! I18n - Easy-to-use and extensible framework for translating your application to a single custom language other than English or for providing multi-language support in your application. Every static string in the Rails framework — e.g. Active Record validation messages, time and date formats — has been internationalized You may be tempted to store the chosen locale in a session or a cookie. Do not do so. The locale should be transparent and a part of the URL. This way you don’t break people’s basic assumptions about the web itself: if you send a URL of some page to a http://guides.rubyonrails.org/i18n.html Maciej Mensfeld

  4. Chapter 4.1 – DeeperintoRails I18n – we speakdifferentlanguages! Applicationcontroller: Maciej Mensfeld

  5. Chapter 4.1 – DeeperintoRails I18n – we speakdifferentlanguages! Tryit out! Maciej Mensfeld

  6. Chapter 4.1 – DeeperintoRails I18n – we speakdifferentlanguages! Tryit out! Maciej Mensfeld

  7. Chapter 4.1 – DeeperintoRails I18n – we speakdifferentlanguages! Workout time! ruby -Itest test/unit/i18n_test.rb Maciej Mensfeld

  8. Chapter 4.1 – DeeperintoRails Be RESTful as much as youcan be! Representational State Transfer Representational State Transfer (REST) is a style of software architecture for distributed systems such as the World Wide Web. • Scalability of component interactions • Generality of interfaces • Independent deployment of components • Intermediary components to reduce latency, enforce security and encapsulate legacy systems Maciej Mensfeld

  9. Chapter 4.1 – DeeperintoRails Be RESTful as much as youcan be! Don’tworkwithdifferentmodelsin one controller! Don’tuse non standard actions (unlessyoureallyknowwhatyouaredoing!) Thinkwith resources, not withactions! Userestfulroutes (resources :users, etc) Maciej Mensfeld

  10. Chapter 4.1 – DeeperintoRails Be RESTful as much as youcan be! Usescopes and namespaces! Namespacesaregood to separatedifferentlogicwith same controllernames(in differentmodules) Namespacingstuffhelpsyoumanagegrowingprojects Maciej Mensfeld

  11. Chapter 4.1 – DeeperintoRails plataformatec / Responders https://github.com/plataformatec/responders Sets the flash based on the controller action and resource status. Installationprocess: Maciej Mensfeld

  12. Chapter 4.1 – DeeperintoRails plataformatec / Responders Respondersusesthe ‘valid?’ method to determinewhetheror not theobjectpassed to ‘respond_with’ isvalid Youcanalso pass a :locationparameter to redirect to a specifiedroute Maciej Mensfeld

  13. Chapter 4.1 – DeeperintoRails plataformatec / Responders Workout time! Install and useresponders for our Post model inourexampleapp(orinyourapp for a selected model) Maciej Mensfeld

  14. Chapter 4.1 – DeeperintoRails Simplecov – Codecoverage Code coverage is a measure used in software testing. It describes the degree to which the source code of a program has been tested. Primary gem for codecoveragein Ruby projectisSimplecov The main advantage of running a coverage tool on your test suite is to find areas of your code that are poorly tested. Maciej Mensfeld

  15. Chapter 4.1 – DeeperintoRails Simplecov – Codecoverage Edit: test_helper.rb ruby -Itest test/unit/user_test.rb ViewRails.root/coverage.index.html Maciej Mensfeld

  16. Chapter 4.1 – DeeperintoRails Haml + Simple form Haml (HTML abstraction markup language) is based on one primary principle: markup should be beautiful. It’s not just beauty for beauty’s sake either; Haml accelerates and simplifies template creation down to veritable haiku. gem ‘haml’ # Gemfile=> bundleinstall Maciej Mensfeld

  17. Chapter 4.1 – DeeperintoRails Haml + Simple form By defaultHamlusesDIVs Classdeclarationstartswithdot (.class_name) Id declarationstartswithhash (#super_id) To create „not DIV” use % (%h2) All Hamlelementscloseautomatically Youcan mix id, class and otherattributes! Richexample: %h3.extra#content{:title => ‘Headertitle’} Maciej Mensfeld

  18. Chapter 4.1 – DeeperintoRails Haml + Simple form Workout time! ChangeyourApplayoutfrom erb to haml. Changeyour Post viewsfrom erb to haml HTML2HAML converter: http://html2haml.heroku.com/ Maciej Mensfeld

  19. Chapter 4.1 – DeeperintoRails Haml + Simple form SimpleForm aims to be as flexible as possible while helping you with powerful components to create your forms. The basic goal of SimpleForm is to not touch your way of defining the layout, letting you find the better design for your eyes. Rails forms made easy https://github.com/plataformatec/simple_form Maciej Mensfeld

  20. Chapter 4.1 – DeeperintoRails Haml + Simple form Simple form can be usedwith erb orhamltemplates(orwithboth) Maciej Mensfeld

  21. Chapter 4.1 – DeeperintoRails Haml + Simple form Workout time! ChangeyourformsfromRailsstdforms to simple form https://github.com/plataformatec/simple_form Maciej Mensfeld

  22. Chapter 4.1 – DeeperintoRails Live long and prosper! Presented by: Maciej Mensfeld maciej@mensfeld.pl mensfeld.pl github.com/mensfeld Maciej Mensfeld

More Related