SlideShare a Scribd company logo
1 of 26
1
2
3
4
5
6
7
app/
                                                controllers
                                (2)
                config/
               routes.rb

       (1)                                                          (3)
                                      (5)                     (4)

User
         (6)


                                                                    app/models
                    app/views




                                            8
9
10
11
class You
  def self.hello     You.hello # hello
   puts “hello”      you = You.new
  end                you.hello # error
                     you.morning # morning
  def morning
   puts “morning”
  end
end



                    12
a = 120
a = 100             if a == 100
if a == 100           puts "100!"
  puts "100!"       elsif a == 120
else                  puts "120!"
  puts "not 100!"   else
end                   puts “?”
                    end




                    13
list = [1,2,3]           list = [1,2,3]
list.each do |it|        list.each { |it|
  puts it                  puts it
end                      }




                    14
"a".twice # error   class You
                      private
class String          def secret
  def twice            puts “sleeping”
   self + self        end
  end               end
end                 you = You.new
                    you.secret # error
"a".twice # => "aa' you.send(:secret) # =>
                    sleeping

                      15
16
17
class BlogsController
  def index # <=
 end
 def edit
 end
end


                        18
class Blog < ActiveRecord::Base
end




                     19
app/views/blogs/{action}.html.erb



app/views/layouts/blogs.html.erb
or
app/views/layouts/application.html.erb


                   20
<%= 100 %>

<% if a == 100 %>
<div>Hello!</div>
<% end %>

<%# comment %>


                    21
<%= render 'form' %>
_form.html.erb




                 22
class BlogsController
  def index # <=         <% @list.each do |it| %>
                         <div><%= it %></div>
  @list = [1,2,3]        <% end %>
   @list.pop
 end
 def edit
 end
end




                        23
24
>> entry = Blog.first

>> entry.title

>> entry.title = “heeeelp”
>> entry.save



                       25
class Blog < ActiveRecord::Base
end
                        class CreateBlogs < ActiveRecord::Migration
                          def self.up
>> entry = Blog.first       create_table :blogs do |t|
>> entry.title               t.string :title
                             t.text :body

                            t.timestamps
                          end
                         end
                        end




                       26

More Related Content

What's hot

Silex: From nothing to an API
Silex: From nothing to an APISilex: From nothing to an API
Silex: From nothing to an APIchrisdkemper
 
16.mysql stored procedures in laravel
16.mysql stored procedures in laravel16.mysql stored procedures in laravel
16.mysql stored procedures in laravelRazvan Raducanu, PhD
 
Les exceptions, oui, mais pas n'importe comment
Les exceptions, oui, mais pas n'importe commentLes exceptions, oui, mais pas n'importe comment
Les exceptions, oui, mais pas n'importe commentCharles Desneuf
 
優しいWAFの作り方
優しいWAFの作り方優しいWAFの作り方
優しいWAFの作り方techmemo
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
How to develop modern web application framework
How to develop modern web application frameworkHow to develop modern web application framework
How to develop modern web application frameworktechmemo
 
TYPO3 Flow 2.0 (T3CON13 San Francisco)
TYPO3 Flow 2.0 (T3CON13 San Francisco)TYPO3 Flow 2.0 (T3CON13 San Francisco)
TYPO3 Flow 2.0 (T3CON13 San Francisco)Robert Lemke
 
Awash in a sea of connections
Awash in a sea of connectionsAwash in a sea of connections
Awash in a sea of connectionsGalen Charlton
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPresswpnepal
 
ZCPE - PHP Conference 2015
ZCPE   - PHP Conference 2015ZCPE   - PHP Conference 2015
ZCPE - PHP Conference 2015Matheus Marabesi
 
Be happy with Ruby on Rails - CEUNSP Itu
Be happy with Ruby on Rails - CEUNSP ItuBe happy with Ruby on Rails - CEUNSP Itu
Be happy with Ruby on Rails - CEUNSP ItuLucas Renan
 
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...Matheus Marabesi
 
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For KohaPutting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For KohaGalen Charlton
 
Laravel Design Patterns
Laravel Design PatternsLaravel Design Patterns
Laravel Design PatternsBobby Bouwmann
 
Generating Power with Yield
Generating Power with YieldGenerating Power with Yield
Generating Power with YieldJason Myers
 
Limited return type covariance and argument type contravariance
Limited return type covariance and argument type contravarianceLimited return type covariance and argument type contravariance
Limited return type covariance and argument type contravariancenob f
 
Getting out of Callback Hell in PHP
Getting out of Callback Hell in PHPGetting out of Callback Hell in PHP
Getting out of Callback Hell in PHPArul Kumaran
 
Silex and Twig (PHP Dorset talk)
Silex and Twig (PHP Dorset talk)Silex and Twig (PHP Dorset talk)
Silex and Twig (PHP Dorset talk)Dave Hulbert
 

What's hot (20)

Silex: From nothing to an API
Silex: From nothing to an APISilex: From nothing to an API
Silex: From nothing to an API
 
Complex Sites with Silex
Complex Sites with SilexComplex Sites with Silex
Complex Sites with Silex
 
16.mysql stored procedures in laravel
16.mysql stored procedures in laravel16.mysql stored procedures in laravel
16.mysql stored procedures in laravel
 
Les exceptions, oui, mais pas n'importe comment
Les exceptions, oui, mais pas n'importe commentLes exceptions, oui, mais pas n'importe comment
Les exceptions, oui, mais pas n'importe comment
 
優しいWAFの作り方
優しいWAFの作り方優しいWAFの作り方
優しいWAFの作り方
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
How to develop modern web application framework
How to develop modern web application frameworkHow to develop modern web application framework
How to develop modern web application framework
 
TYPO3 Flow 2.0 (T3CON13 San Francisco)
TYPO3 Flow 2.0 (T3CON13 San Francisco)TYPO3 Flow 2.0 (T3CON13 San Francisco)
TYPO3 Flow 2.0 (T3CON13 San Francisco)
 
Awash in a sea of connections
Awash in a sea of connectionsAwash in a sea of connections
Awash in a sea of connections
 
The Symfony CLI
The Symfony CLIThe Symfony CLI
The Symfony CLI
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
 
ZCPE - PHP Conference 2015
ZCPE   - PHP Conference 2015ZCPE   - PHP Conference 2015
ZCPE - PHP Conference 2015
 
Be happy with Ruby on Rails - CEUNSP Itu
Be happy with Ruby on Rails - CEUNSP ItuBe happy with Ruby on Rails - CEUNSP Itu
Be happy with Ruby on Rails - CEUNSP Itu
 
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...
 
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For KohaPutting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
 
Laravel Design Patterns
Laravel Design PatternsLaravel Design Patterns
Laravel Design Patterns
 
Generating Power with Yield
Generating Power with YieldGenerating Power with Yield
Generating Power with Yield
 
Limited return type covariance and argument type contravariance
Limited return type covariance and argument type contravarianceLimited return type covariance and argument type contravariance
Limited return type covariance and argument type contravariance
 
Getting out of Callback Hell in PHP
Getting out of Callback Hell in PHPGetting out of Callback Hell in PHP
Getting out of Callback Hell in PHP
 
Silex and Twig (PHP Dorset talk)
Silex and Twig (PHP Dorset talk)Silex and Twig (PHP Dorset talk)
Silex and Twig (PHP Dorset talk)
 

Similar to Rails3ハンズオン資料

Ruby on Rails at PROMPT ISEL '11
Ruby on Rails at PROMPT ISEL '11Ruby on Rails at PROMPT ISEL '11
Ruby on Rails at PROMPT ISEL '11Pedro Cunha
 
Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Railsrstankov
 
Blocks by Lachs Cox
Blocks by Lachs CoxBlocks by Lachs Cox
Blocks by Lachs Coxlachie
 
Simple restfull app_s
Simple restfull app_sSimple restfull app_s
Simple restfull app_snetwix
 
Rails best practices_slides
Rails best practices_slidesRails best practices_slides
Rails best practices_slidesCao Van An
 
Say Goodbye to Procedural Programming - Nick Sutterer
Say Goodbye to Procedural Programming - Nick SuttererSay Goodbye to Procedural Programming - Nick Sutterer
Say Goodbye to Procedural Programming - Nick SuttererRuby Meditation
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends旻琦 潘
 
Rails workshop for Java people (September 2015)
Rails workshop for Java people (September 2015)Rails workshop for Java people (September 2015)
Rails workshop for Java people (September 2015)Andre Foeken
 
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code styleRuby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code styleAnton Shemerey
 
Ruby Metaprogramming
Ruby MetaprogrammingRuby Metaprogramming
Ruby MetaprogrammingThaichor Seng
 
Ruby on Rails ステップアップ講座 - 大場寧子
Ruby on Rails ステップアップ講座 - 大場寧子Ruby on Rails ステップアップ講座 - 大場寧子
Ruby on Rails ステップアップ講座 - 大場寧子Yasuko Ohba
 

Similar to Rails3ハンズオン資料 (20)

Ruby on Rails at PROMPT ISEL '11
Ruby on Rails at PROMPT ISEL '11Ruby on Rails at PROMPT ISEL '11
Ruby on Rails at PROMPT ISEL '11
 
Ruby on Rails
Ruby on RailsRuby on Rails
Ruby on Rails
 
Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Rails
 
Why ruby
Why rubyWhy ruby
Why ruby
 
Migrating legacy data
Migrating legacy dataMigrating legacy data
Migrating legacy data
 
Ruby
RubyRuby
Ruby
 
Blocks by Lachs Cox
Blocks by Lachs CoxBlocks by Lachs Cox
Blocks by Lachs Cox
 
Simple restfull app_s
Simple restfull app_sSimple restfull app_s
Simple restfull app_s
 
Rails best practices_slides
Rails best practices_slidesRails best practices_slides
Rails best practices_slides
 
Say Goodbye to Procedural Programming - Nick Sutterer
Say Goodbye to Procedural Programming - Nick SuttererSay Goodbye to Procedural Programming - Nick Sutterer
Say Goodbye to Procedural Programming - Nick Sutterer
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends
 
Module Magic
Module MagicModule Magic
Module Magic
 
Rails workshop for Java people (September 2015)
Rails workshop for Java people (September 2015)Rails workshop for Java people (September 2015)
Rails workshop for Java people (September 2015)
 
Tres Gemas De Ruby
Tres Gemas De RubyTres Gemas De Ruby
Tres Gemas De Ruby
 
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code styleRuby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
 
Ruby Intro {spection}
Ruby Intro {spection}Ruby Intro {spection}
Ruby Intro {spection}
 
Ruby Metaprogramming
Ruby MetaprogrammingRuby Metaprogramming
Ruby Metaprogramming
 
An introduction to Ruby
An introduction to RubyAn introduction to Ruby
An introduction to Ruby
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
Ruby on Rails ステップアップ講座 - 大場寧子
Ruby on Rails ステップアップ講座 - 大場寧子Ruby on Rails ステップアップ講座 - 大場寧子
Ruby on Rails ステップアップ講座 - 大場寧子
 

More from Shinsaku Chikura

ギークな人たちの最新トレンド を『下北沢オープンソース Cafe水曜部』でキャッチしよ う♪
ギークな人たちの最新トレンド を『下北沢オープンソース Cafe水曜部』でキャッチしよ う♪ギークな人たちの最新トレンド を『下北沢オープンソース Cafe水曜部』でキャッチしよ う♪
ギークな人たちの最新トレンド を『下北沢オープンソース Cafe水曜部』でキャッチしよ う♪Shinsaku Chikura
 
図書館のアーキテクチャを考える
図書館のアーキテクチャを考える図書館のアーキテクチャを考える
図書館のアーキテクチャを考えるShinsaku Chikura
 
オンラインタスク管理ツールをWebサービス開発と運用に役立てよう!
オンラインタスク管理ツールをWebサービス開発と運用に役立てよう!オンラインタスク管理ツールをWebサービス開発と運用に役立てよう!
オンラインタスク管理ツールをWebサービス開発と運用に役立てよう!Shinsaku Chikura
 
リブライズの裏側を見てみよう
リブライズの裏側を見てみようリブライズの裏側を見てみよう
リブライズの裏側を見てみようShinsaku Chikura
 
オープンソースで広がるFacebookアプリの世界
オープンソースで広がるFacebookアプリの世界オープンソースで広がるFacebookアプリの世界
オープンソースで広がるFacebookアプリの世界Shinsaku Chikura
 
環境問題から考えるRails入門
環境問題から考えるRails入門環境問題から考えるRails入門
環境問題から考えるRails入門Shinsaku Chikura
 

More from Shinsaku Chikura (9)

ギークな人たちの最新トレンド を『下北沢オープンソース Cafe水曜部』でキャッチしよ う♪
ギークな人たちの最新トレンド を『下北沢オープンソース Cafe水曜部』でキャッチしよ う♪ギークな人たちの最新トレンド を『下北沢オープンソース Cafe水曜部』でキャッチしよ う♪
ギークな人たちの最新トレンド を『下北沢オープンソース Cafe水曜部』でキャッチしよ う♪
 
WebPay on Rails
WebPay on RailsWebPay on Rails
WebPay on Rails
 
図書館のアーキテクチャを考える
図書館のアーキテクチャを考える図書館のアーキテクチャを考える
図書館のアーキテクチャを考える
 
オンラインタスク管理ツールをWebサービス開発と運用に役立てよう!
オンラインタスク管理ツールをWebサービス開発と運用に役立てよう!オンラインタスク管理ツールをWebサービス開発と運用に役立てよう!
オンラインタスク管理ツールをWebサービス開発と運用に役立てよう!
 
リブライズの裏側を見てみよう
リブライズの裏側を見てみようリブライズの裏側を見てみよう
リブライズの裏側を見てみよう
 
オープンソースで広がるFacebookアプリの世界
オープンソースで広がるFacebookアプリの世界オープンソースで広がるFacebookアプリの世界
オープンソースで広がるFacebookアプリの世界
 
Facebootstrap
FacebootstrapFacebootstrap
Facebootstrap
 
Jump into Rails3
Jump into Rails3Jump into Rails3
Jump into Rails3
 
環境問題から考えるRails入門
環境問題から考えるRails入門環境問題から考えるRails入門
環境問題から考えるRails入門
 

Rails3ハンズオン資料

  • 1. 1
  • 2. 2
  • 3. 3
  • 4. 4
  • 5. 5
  • 6. 6
  • 7. 7
  • 8. app/ controllers (2) config/ routes.rb (1) (3) (5) (4) User (6) app/models app/views 8
  • 9. 9
  • 10. 10
  • 11. 11
  • 12. class You def self.hello You.hello # hello puts “hello” you = You.new end you.hello # error you.morning # morning def morning puts “morning” end end 12
  • 13. a = 120 a = 100 if a == 100 if a == 100 puts "100!" puts "100!" elsif a == 120 else puts "120!" puts "not 100!" else end puts “?” end 13
  • 14. list = [1,2,3] list = [1,2,3] list.each do |it| list.each { |it| puts it puts it end } 14
  • 15. "a".twice # error class You private class String def secret def twice puts “sleeping” self + self end end end end you = You.new you.secret # error "a".twice # => "aa' you.send(:secret) # => sleeping 15
  • 16. 16
  • 17. 17
  • 18. class BlogsController def index # <= end def edit end end 18
  • 19. class Blog < ActiveRecord::Base end 19
  • 21. <%= 100 %> <% if a == 100 %> <div>Hello!</div> <% end %> <%# comment %> 21
  • 22. <%= render 'form' %> _form.html.erb 22
  • 23. class BlogsController def index # <= <% @list.each do |it| %> <div><%= it %></div> @list = [1,2,3] <% end %> @list.pop end def edit end end 23
  • 24. 24
  • 25. >> entry = Blog.first >> entry.title >> entry.title = “heeeelp” >> entry.save 25
  • 26. class Blog < ActiveRecord::Base end class CreateBlogs < ActiveRecord::Migration def self.up >> entry = Blog.first create_table :blogs do |t| >> entry.title t.string :title t.text :body t.timestamps end end end 26

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n