adrian-gomez / swaggard

Add Swagger documentation to your Rails REST endpoints.
MIT License
54 stars 38 forks source link

The asset "application.css" is not present in the asset pipeline. #39

Open csivladislavbakan opened 7 years ago

csivladislavbakan commented 7 years ago

Create test rails application and add swaggard gem to gemfile (swaggard configuration doesn't matter, it happens anyway). Any route opening causes error "The asset "application.css" is not present in the asset pipeline." There is stack trace

app/views/layouts/application.html.erb where line #7 raised:

5    <%= csrf_meta_tags %>
6
7    <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
8    <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
9  </head>

And it's my gemfile

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

gem 'rails', '~> 5.1.2'
gem 'sqlite3'
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'

gem 'swaggard'

gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'

group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'capybara', '~> 2.13'
  gem 'selenium-webdriver'
end

group :development do
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
vladislavbakan commented 7 years ago

I think, i found issue. In Swaggard gem file lib/swaggard/engine.rb contains next line of code: initializer 'swaggard.finisher_hook', after: :finisher_hook do |app| I'm not familiar with it, but i just deleted finisher_hook and it started work for me. Now this line seems like initializer 'swaggard.finisher_hook' do |app| Could you please explain what finisher_hook does and why it has this strange impact. Thanks in advance

nicpillinger commented 6 years ago

This bit us when upgrading a rails 4.2 app to rails 5.1 - completely broke the app and it wasnt obvious it was swaggard causing the issue (it looks like its to do with the asset pipeline).

nicpillinger commented 6 years ago

This might be useful: https://github.com/rails/sprockets-rails/pull/388

software-project commented 6 years ago

Same issue here. Is there a fix for this one?

csivladislavbakan commented 6 years ago

You can change one line in lib/swaggard/engine.rb (initializer 'swaggard.finisher_hook', after: :finisher_hook do |app| -> initializer 'swaggard.finisher_hook' do |app|) or just use my fork

software-project commented 6 years ago

@csivladislavbakan your fork causes different error with warden undefined method failure_app=' for nil:NilClass (NoMethodError)

johan-smits commented 4 years ago

To me this was still an issue. Added PR #50 to solve this.