1 / 23

Ruby Web Applications: Frameworks, Features, and Commands

Explore the foundation of Ruby web applications, including frameworks like Ruby on Rails and Sinatra, features and advantages, and essential commands for development and management.

Télécharger la présentation

Ruby Web Applications: Frameworks, Features, and Commands

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. 1 DAY5: THE FOUNDATION OF RUBY dblab-study ruby seminar 2011/9/29

  2. What is web applications? 2 A web application is an application that is accessed over a network such as the Internet or an intranet. 2011/9/23

  3. Web applications features Advantages Cross Platform Don't need install Always newest application 3 Disadvantages • When not running the server application can not be used • Can not connect to the internet and not use • Simply can not erase the data 2011/9/23

  4. HTTP methods How to send data to a Web server mainly include two methods. get To add a parameter to the url post Sends the data to post without displaying the url parameter 4 2011/9/23

  5. Framework A collection of commonly used functions such as libraries and compiled in order to implement the application. Java Spring, Struts, SAStruts C++, C# .net framework Ruby Ruby on Rails, Sinatra 5 2011/9/23

  6. Ruby on Rails (RoR) Rails is running ruby web frameworks. You can write a program in the mvc model. 6 2011/9/23

  7. rails new command rails new “app name” -options rails new command is to create a rails application stationery. example rails new myApp -d postgresql 7 2011/9/23

  8. rake db:create command rake db:create create db command “create db 'app name'” in postgresql exemple rake db:create 8 2011/9/23

  9. rails generate command rails generate scaffold “model” “attributes” The CRUD screen about model class and model is generated. exemple rails generate scaffold entry title:string contents:text 9 2011/9/23

  10. rails generate command rails generate controller “controller” “action” A controller and action are generated. exemple rails g entry view rails generate model “model” “attributes” Only model is generated. exemple rails g model user name:string age:integer

  11. rake db:migrate command rake db:migrate The fixtures file generated by rails is reflected on a database. “create table 'models' ” in postgrsql exemple rake db:migrate 11 2011/9/23

  12. rails server command rails server (-option) Run the rails application port number 3000 if you would like to stop a server, it will be stopped by Ctrl+c exemple rails server 12 2011/9/23

  13. Controller controller carries out the role which receives the request sent by the user, calls model and returns view. render render is a method which specifies the template of html to display. redirect redirect is a method for making a user change to other pages. 13 2011/9/23

  14. Routing In rails, if it accesses by what kind of URI, it can be set up whether action is performed. in config/routs.rb resource :modelname The path of CRUD to a model is generated. match 'apppath' => 'controller/model'

  15. Model models are an entity of a database, and a class corresponding to 1 to 1. activeRecord is OR mapper for making the data of ruby to DB easy to treat. 15 2011/9/23

  16. The function of activeRecord The relation in DB is added to a model class. has_many :models belongs_to :model The one to many relation in a database can be expressed. A database can be accessed more abstractly. scope :name, :conditions Conditions can be transposed to a thing like a function. “data collections”.sum(:column) 16 2011/9/23

  17. View Ruby can be embedded at html. (ERB file) <%= “ruby code”%> <%= text_field_tag :comment, "test" %> <input type="text" name="comment" value="test" />

  18. rails console command rails console (-option) It is a command which starts irb where the information on rails application is read.

  19. RubyGems RubyGems is a library management tool of ruby. gem 'library name' install library gem list show installed library list gem search 'library name' search ruby library When looking for a gem library, the ruby toolbox is convenient. http://ruby-toolbox.com/

  20. bundler The Bundler command is used for management of the dependency of a gem file. Since a library can be collectively installed when developing by two or more persons, it is convenient. such as maven2 in java bundle install gem currently written to Gemfile is installed.

  21. Other command (1) rake db:fixtures:extruct The information on the present DB is dumped by a yml file. rake db:fixtures:load Data is inserted in DB from a yml file. rake routes A setup of routing of application can see.

  22. Other command (2) rails runner 'ruby file' ruby can be performed in the environment of rails application. It mainly uses by a batch program. gem server If "http://localhost:8808" is accessed by a browser, the document of Gem installed can be read.

  23. Reference Rails3レシピブック 190の技 ISBN-13: 978-4797363821 The Ruby Toolbox http://ruby-toolbox.com/ RailsGuides http://guides.rubyonrails.org/ Rails API http://api.rubyonrails.org/

More Related