Your SlideShare is downloading. ×
  • Like
Rails e suas Gems
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply
Published

 

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
824
On SlideShare
0
From Embeds
0
Number of Embeds
4

Actions

Shares
Downloads
2
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Rails e suas Gems @rr_martins Rodrigo Martins [email_address]
  • 2. Gems? É bom assim por dentro?
  • 3. Gems?
    • http://docs.rubygems.org/
    • Gerenciador de pacotes do Ruby.
    Uiiii... Uma Joia... :D
  • 4. Um pouco de Ruby! (String)
    • >> string = " liberdade Interativa! eu Fui!"
    • => " liberdade Interativa! eu Fui!"
    • >> def chamada(evento="LI")
    • >> puts evento.to_s+" Eu fui!"
    • >> end
    • >> chamada("Liberdade Interativa")
    • => Liberdade Interativa Eu fui!
    • >> chamada
    • => LI Eu fui!
  • 5. Um pouco de Ruby! (Array)
    • >> evento = Array.new
    • >> evento << &quot;LI&quot;
    • => [&quot;LI&quot;]
    • >> evento << &quot;Liberdade Interativa&quot;
    • => [&quot;LI&quot;, &quot;Liberdade Interativa&quot;]
    • >> evento << &quot;RockOnRails&quot;
    • => [&quot;LI&quot;, &quot;Liberdade Interativa&quot;, &quot;RockOnRails&quot;]
  • 6. Um pouco de Ruby! (Array)
    • >> def chamada(evento)
    • >> evento.each do |even|
    • >> puts even.to_s+&quot; Eu Fui! :D&quot;
    • >> end
    • >> end
    • >> chamada(evento)
    • => LI Eu Fui! :D
    • => Liberdade Interativa Eu Fui! :D
    • => RockOnRails Eu Fui! :D
  • 7. Já posso usar as Gems? Calma! Vamos com calma, as Gems precisam do Rails!
  • 8. Projeto Blog!
  • 9. Gems Apresentadas!
    • -> Paperclip->github.com/thoughtbot/paperclip
    • Sugestão: Rodrigo Mendonça (rails-br)
    • -> Devise -> github.com/plataformatec/devise
    • Sugestão: Celso Dantas (rails-br)
    • -> Twitter -> github.com/jnunemaker/twitter
  • 10. Projeto Rails criado..
    • rails new <projeto>
  • 11. Gems Apresentadas!
    • -> Paperclip
    • -> github.com/thoughtbot/paperclip
    • Sugestão: Rodrigo Mendonça (rails-br)
    • -> Devise -> github.com/plataformatec/devise
    • Sugestão: Celso Dantas (rails-br)
    • -> Twitter -> github.com/jnunemaker/twitter
  • 12. PaperClip
    • No GemFile:
    • gem &quot;paperclip&quot;, &quot;~> 2.4&quot;
    • No Model: (Post)
    • has_attached_file :image, :styles => { :medium => &quot;300x300>&quot;, :thumb => &quot;100x100>&quot; }
  • 13. PaperClip
    • Migrate :
    • class AddImageToPost < ActiveRecord::Migration
    • def self.up
    • add_column :posts, :image_file_name, :string
    • add_column :posts, :image_content_type, :string
    • add_column :posts, :image_file_size, :integer
    • add_column :posts, :image_updated_at, :datetime
    • end
    • def self.down
    • remove_column :posts, :image_updated_at
    • remove_column :posts, :image_file_size
    • remove_column :posts, :image_content_type
    • remove_column :posts, :image_file_name
    • end
    • end
  • 14. PaperClip
    • <%= form_for :post, :url => posts_path, :
      • html => { :class => :form, :multipart => true } do |f| -%>
    • <div class=&quot;field&quot;>
    • <strong><%= f.label :data %></strong>
    • <%= f.hidden_field :data, :value => Time.now %>
    • <%= f.label Time.now.to_date %>
    • </div>
    • <div class=&quot;field&quot;>
    • <%= f.label :titulo %><br />
    • <%= f.text_field :titulo %>
    • </div>
    • <div class=&quot;field&quot;>
    • <%= f.label :chamada %><br />
    • <%= f.text_field :chamada %>
    • </div>
  • 15. PaperClip
    • <div class=&quot;field&quot;>
    • <%= f.label :texto %><br />
    • <%= f.text_area :texto %>
    • </div>
    • <div class=&quot;field&quot;>
    • <%= f.label &quot;Imagem&quot; %>
    • <%= f.file_field :image %>
    • </div>
    • <div class=&quot;actions&quot;>
    • <%= f.submit %>
    • </div>
    • <% end -%>
  • 16. PaperClip
    • View Show:
    • <%= image_tag @post.image.url if !@post.image_file_name.nil? %>
    • <%= image_tag @post.image.url(:medium) if !@post.image_file_name.nil? %>
    • <%= image_tag @post.image.url(:thumb) if !@post.image_file_name.nil? %>
  • 17. PaperClip
  • 18. Gems Apresentadas!
    • -> Paperclip->github.com/thoughtbot/paperclip
    • Sugestão: Rodrigo Mendonça (rails-br)
    • -> Devise -> github.com/plataformatec/devise
    • Sugestão: Celso Dantas (rails-br)
    • -> Twitter -> github.com/jnunemaker/twitter
  • 19. Devise
  • 20. Devise
    • Gemfile:
    • gem “devise”
    • Iniciando o Devise:
    • rails generate devise:install
    • Configurando um model:
    • rails generate devise usuario
  • 21. Devise
  • 22. Devise
    • Rodando Migrate:
  • 23. Devise
    • Autenticando Controller:
    • before_filter :authenticate_user!
    • before_filter :authenticate_user!,
    • :except => [:index, :show, :create]
  • 24. Gems Apresentadas!
    • -> Paperclip->github.com/thoughtbot/paperclip
    • Sugestão: Rodrigo Mendonça (rails-br)
    • -> Devise -> github.com/plataformatec/devise
    • Sugestão: Celso Dantas (rails-br)
    • -> Twitter -> github.com/jnunemaker/twitter
  • 25. Twitter
  • 26. Twitter
    • GemFile:
    • gem 'twitter'
  • 27. Twitter
    • <table border=&quot;0&quot;>
    • <tr>
    • <td><%= image_tag Twitter.profile_image(&quot;rr_martins&quot;, :size => 'bigger') %></td>
    • <td><%= Twitter.user('rr_martins').location %>
    • <br> <%= Twitter.user('rr_martins').description %>
    • </td>
  • 28. Twitter
    • </tr>
    • <% Twitter.user_timeline(&quot;rr_martins&quot;,{:count=>5}).each do |twit| %>
    • <tr>
    • <td colspan=&quot;2&quot;><%= twit.text %></td>
    • </tr>
    • <% end %>
    • </table>
  • 29. Fontes
    • http://github.com
    • https://www.ruby-toolbox.com
    • http://rubygems.org/
    • Em breve:
    • http://rrmartins.com
    • https://github.com/rrmartins/blog
  • 30. Duvidas? @rr_martins Rodrigo Martins [email_address]
  • 31. Obrigado! @rr_martins Rodrigo Martins [email_address]