• Home
  • Jobs
  • coursesAndChallenges
  • Teachers
  • For business
  • Blog
  • ES/EN

0

36
Views
Lazy Load to image_tag Rails

So apparently this commit adds a configuration option to define the default value of the image_tag :loading option. Thus by setting, config.action_view.image_loading an application can opt in to lazy loading images sitewide, without changing view code.

config.action_view.image_loading = "lazy"

However when I try to add it to my development.rb or production.rb I get the following error :

1: from /Users/cash/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/actionview-6.1.3.2/lib/action_view/railtie.rb:46:in `each'
/Users/cash/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/actionview-6.1.3.2/lib/action_view/railtie.rb:53:in `block (3 levels) in <class:Railtie>': undefined method `image_loading=' for ActionView::Base:Class (NoMethodError)

Rails version: 6.1.3.2

Ruby version: ruby 2.7.1p83

about 1 month ago ·

Santiago Trujillo

1 answers
Answer question

0

This is not yet available in stable rails, it will be available in rails 7, and if you need to do it now, you can switch to depend on the git main head:

git 'https://github.com/rails/rails.git' do
  gem 'railties'
  gem 'actionpack'
  gem 'activemodel'
end

You can see it by going to the merge commit: https://github.com/rails/rails/commit/3c2a80d8b1d4730897a7040b7f563d0027aa1e83 and checking just below the title. It shows the branches and tags this commit belongs to (in this case, only main):

enter image description here

about 1 month ago · Santiago Trujillo Report
Answer question
Remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Startups
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.