Hidden things from Rails 5

1b0973b64704738dbc8ce24d8382bb1f?s=47 Prathamesh
March 18, 2017
260

Hidden things from Rails 5

Talk given at Rubyconf.ph 2017

1b0973b64704738dbc8ce24d8382bb1f?s=128

Prathamesh

March 18, 2017
Tweet

Transcript

  1. 3.
  2. 10.

    PHP

  3. 11.
  4. 13.
  5. 15.

    5

  6. 16.

    5

  7. 17.

    5

  8. 18.

    5

  9. 19.
  10. 21.
  11. 40.

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

    _todo.html.erb <% cache todo do %> <%= todo.name %> <% end %>
  12. 41.

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

    _todo.html.erb <% cache todo do %> <%= todo.name %> <% end %>
  13. 42.
  14. 44.

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

    %> # _todo.html.erb <% cache todo do %> <%= todo.name %> <% end %>
  15. 45.
  16. 51.

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

    < ActiveJob::Base self.queue_adapter = :delayed_job end
  17. 52.

    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>
  18. 63.

    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
  19. 73.
  20. 74.
  21. 76.

    def create @post = Post.new(post_params) if @post.save redirect_to @post, notice:

    'Post was successfully created.’ else render ‘new’ end end
  22. 77.

    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)
  23. 79.
  24. 80.

    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)
  25. 81.

    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)
  26. 90.

    >> 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
  27. 94.

    <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>
  28. 95.

    <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>
  29. 96.

    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
  30. 100.