Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hidden things from Rails 5

Prathamesh Sonpatki
March 18, 2017
310

Hidden things from Rails 5

Talk given at Rubyconf.ph 2017

Prathamesh Sonpatki

March 18, 2017
Tweet

Transcript

  1. PHP

  2. 5

  3. 5

  4. 5

  5. 5

  6. # index.html.erb <%= render partial: 'todo', collection: @todos %> #

    _todo.html.erb <% cache todo do %> <%= todo.name %> <% end %>
  7. # index.html.erb <%= render partial: 'todo', collection: @todos %> #

    _todo.html.erb <% cache todo do %> <%= todo.name %> <% end %>
  8. # index.html.erb <%= render partial: 'todo', collection: @todos, cached: true

    %> # _todo.html.erb <% cache todo do %> <%= todo.name %> <% end %>
  9. class EmailJob < ActiveJob::Base self.queue_adapter = :sidekiq end class NewletterJob

    < ActiveJob::Base self.queue_adapter = :delayed_job end
  10. class EmailJob < ActiveJob::Base self.queue_adapter = :sidekiq end class NewletterJob

    < ActiveJob::Base self.queue_adapter = :delayed_job end EmailJob.queue_adapter => #<ActiveJob::QueueAdapters::SidekiqAdapter: 0x007fb3d0b2e4a0> NewletterJob.queue_adapter => #<ActiveJob::QueueAdapters::DealyedJobAdapter: 0x007fb3d0c61b88>
  11. Started GET "/assets/ application.self-4a04ce68c5ebf2d39fba46316802f17d0 a73fadc4d2da50a138d7a4bf2d26a84.css?body=1" for 127.0.0.1 at 2016-09-02 10:23:04

    +0530 Started GET "/assets/bootstrap/ transition.self-6ad2488465135ab731a045a8ebbe3ea2fc 501aed286042496eda1664fdd07ba9.js?body=1" for 127.0.0.1 at 2016-09-02 10:23:04 +0530
  12. def create @post = Post.new(post_params) if @post.save redirect_to @post, notice:

    'Post was successfully created.’ else render ‘new’ end end
  13. Started POST "/posts" for ::1 at 2016-06-02 09:24:53 -0400 Processing

    by PostsController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"FaRp8NUAZWIW0WnMzLpKKQht9WWeTxeSvOvO2GeFpkGbOXzYEnvxTKEZf7gwY 4oy6cW+GRQ3UE6Zu0iXGB4I5A==", "post"=>{"content"=>"hello"}, "commit"=>"Create Post"} (0.2ms) begin transaction SQL (0.3ms) INSERT INTO "posts" ("content", "created_at", "updated_at") VALUES (?, ?, ?) [["content", "hello"], ["created_at", 2016-06-02 13:24:53 UTC], ["updated_at", 2016-06-02 13:24:53 UTC]] (0.7ms) commit transaction Redirected to http://localhost:3000/posts/1 Completed 302 Found in 6ms (ActiveRecord: 1.3ms)
  14. Started POST "/posts" for ::1 at 2016-06-02 09:25:11 -0400 Processing

    by PostsController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"RC46YER7l5yQz1J+DkZIWINBixkaMz9qWWlFzvZT8K3Ksy9IgwADsicHRAryn 4hDYunAZZBLeLZ8OcOBicheCA==", "post"=>{"content"=>"hello 2"}, "commit"=>"Create Post"} (0.0ms) begin transaction SQL (0.2ms) INSERT INTO "posts" ("content", "created_at", "updated_at") VALUES (?, ?, ?) [["content", "hello 2"], ["created_at", 2016-06-02 13:25:11 UTC], ["updated_at", 2016-06-02 13:25:11 UTC]] (1.5ms) commit transaction No template found for PostsController#create, rendering head :no_content Completed 204 No Content in 64ms (ActiveRecord: 2.2ms)
  15. Started POST "/posts" for ::1 at 2016-06-02 09:25:11 -0400 Processing

    by PostsController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"RC46YER7l5yQz1J+DkZIWINBixkaMz9qWWlFzvZT8K3Ksy9IgwADsicHRAryn 4hDYunAZZBLeLZ8OcOBicheCA==", "post"=>{"content"=>"hello 2"}, "commit"=>"Create Post"} (0.0ms) begin transaction SQL (0.2ms) INSERT INTO "posts" ("content", "created_at", "updated_at") VALUES (?, ?, ?) [["content", "hello 2"], ["created_at", 2016-06-02 13:25:11 UTC], ["updated_at", 2016-06-02 13:25:11 UTC]] (1.5ms) commit transaction No template found for PostsController#create, rendering head :no_content Completed 204 No Content in 64ms (ActiveRecord: 2.2ms)
  16. >> user_params.inject DEPRECATION WARNING: Method inject is deprecated and will

    be removed in Rails 5.1, as `ActionController::Parameters` no longer inherits from hash. Using this deprecated behavior exposes potential security problems. If you continue to use this method you may be creating a security vulnerability in your app that can be exploited. Instead, consider using one of these documented methods which are not deprecated: http://api.rubyonrails.org/v5.0.0/classes/ActionController/ Parameters.html
  17. <body> <% cache 'signup-text' do %> <h1>Welcome!</h1> <p>You have successfully

    signed up. Your username is: <br /> <% end %> <%= @user.login %>. <br /> </p> <%= render :partial => 'footer' %> </body>
  18. <body> <% cache 'signup-text' do %> <h1>Welcome!</h1> <p>You have successfully

    signed up. Your username is: <br /> <% end %> <%= @user.login %>. <br /> </p> <%= render :partial => 'footer' %> </body>
  19. Cache digest for app/views/user_mailer/_footer.erb: 7313427d26cc1f701b1e0212498cee38 Cache digest for app/views/user_mailer/welcome_email.html.erb: 30efff0173fd5f29a88ffe79a9eab617

    Rendered user_mailer/_footer.erb (0.3ms) Rendered user_mailer/welcome_email.html.erb (26.1ms) Cache digest for app/views/user_mailer/welcome_email.text.erb: 77f41fe6159c5736ab2026a44bc8de55 Rendered user_mailer/welcome_email.text.erb (0.2ms) UserMailer#welcome_email: processed outbound mail in 190.3ms