PerfectlyNormal / tinymce-rails-imageupload

Image upload plugin for TinyMCE and Rails with the asset pipeline
MIT License
149 stars 153 forks source link

No route matches [GET] "/assets/tinymce/plugins/uploadimage/plugin.js" #53

Closed maxbeizer closed 10 years ago

maxbeizer commented 10 years ago

Hi. First thanks for releasing/maintaining this gem. I'm using Rails 3.2.17, Ruby 2.0.0

gem "tinymce-rails"
gem 'tinymce-rails-imageupload', '~> 4.0.0.beta'
gem 'rack-cache', :require => 'rack/cache'
gem 'dragonfly', '~>0.9.14'
gem "paperclip"
gem "activeadmin"

tinymce-rails is version 4.0.19 activeadmin is version 0.6.3 paperclip is 3.5.1

I am hoping to add imageupload to tinymce-rails in activeadmin and I'm following your README and this tutorial. Everything works well locally.

When I deploy to heroku (cedar stack), the button in the toolbar does not appear and the logs read: ActionController::RoutingError No route matches [GET] "/assets/tinymce/plugins/uploadimage/plugin.js"

Running $ heroku run bash confirms that there is no uploadimage dir in the /public/assets/tinymce/plugins/ but there does appear to be an uploadimage dir at /public/assets . Attempts to mv it have thus far not solved the problem. Any thoughts?

other info

In active_admin.js.coffee

#= require active_admin/base
#= require tinymce
#= require chosen-jquery

$ ->
 tinymce.init
    browser_spellcheck: true
    selector: '.tinymce textarea'
    plugins: 'code link media uploadimage'
    menubar: 'edit format tools'
    toolbar: "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | code link unlink | media uploadimage"

in config/routes

post '/tinymce_assets' => 'tinymce_assets#create'

in tinymce_assets_controller

class TinymceAssetsController < ApplicationController
  def create
    @image = StaticImage.new(:page_image => params[:file])
    @image.save
    render json: {
      image: {
        url: @image.page_image.url
      }
    }, content_type: "text/html"
  end
end
PerfectlyNormal commented 10 years ago

Hi.

Probably something going wrong with the precompilation (as always…). I made a demo-app I use for testing at Heroku (source), but that uses Rails 4.

Do you have any other gems that might interfere, or change things? How are your asset settings in config/environments/production.rb (and development.rb)?

maxbeizer commented 10 years ago

@PerfectlyNormal thanks for getting back to me so quickly!

config/environments/production.rb

  # Disable Rails's static asset server (Apache or nginx will already do this)
  config.serve_static_assets = true

  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Don't fallback to assets pipeline if a precompiled asset is missed
  config.assets.compile = false

  # Generate digests for assets URLs
  config.assets.digest = true

active_admin.js is in the precompile array in application.rb

Also

I tried forking my app on heroku and recreating this section very closely aligned with your demo app and I still receive the same error. I stripped out the dragonfly stuff, tinymce-rails (which I thought was required but apparently not), and that rack-cache gem.

I didn't want to have to do this (for brevity's sake) but here's the entire gemfile of my production app:

source "https://rubygems.org"
ruby "2.0.0"

gem "rails", "3.2.17"
gem "pg"
gem "devise"
gem "activeadmin"
gem "thin"
gem "paperclip"
gem "stringex"
gem "twitter"
gem "rails_autolink"
gem "aws-sdk"
gem "instagram"
gem "tinymce-rails"
gem 'tinymce-rails-imageupload', '~> 4.0.0.beta'
gem 'rack-cache', :require => 'rack/cache'
gem 'dragonfly', '~>0.9.14'
gem "rails-backbone"
gem "backbone-support"
gem "kaminari"
gem "active_model_serializers"
gem "mailchimp-api", require: "mailchimp"
gem "geocoder"
gem "sunspot_rails"
gem "omniauth"
gem "omniauth-facebook"
gem "money-rails"
gem "stripe"
gem 'truncate_html', '~> 0.9.2'
gem "hashie"
gem "rails_12factor"
gem "cancan"

group :assets do
  gem "bitters"
  gem "bourbon"
  gem "coffee-rails", "~> 3.2.1"
  gem "chosen-rails"
  gem "cycle2-rails", "~> 1.1.0"
  gem "fitvids-rails", "~> 1.0.0"
  gem 'fittextjs_rails', '~> 1.2.0.1'
  gem "handlebars_assets", "~> 0.14.1"
  gem "jquery-rails", "2.3.0"
  gem "modernizr-rails", "~> 2.6.2.3"
  gem "neat"
  gem "pickadate-rails"
  gem "sass-rails",   "~> 3.2.3"
  gem "spinjs-rails"
  gem "underscore-rails"
  gem "uglifier", ">= 1.0.3"
  gem "turbo-sprockets-rails3"
end

group :production do
  gem "heroku_rails_deflate"
end

group :development do
  gem "foreman"
  gem "guard-bundler"
  gem "guard-livereload"
  gem "guard-rspec", require: false
  gem "guard-spork"
  gem "rack-livereload"
  gem "rb-fsevent", require: false
  gem "growl"
  gem "better_errors"
  gem "faker"
  gem "sunspot_solr"
  gem "letter_opener"
end

group :development, :test do
  gem "factory_girl_rails"
  gem "pry-rails"
  gem "pry-nav"
  gem "awesome_print"
  gem "quiet_assets"
  gem "heroku"
  gem "rspec-rails"
  gem "dotenv-rails"
end

group :test do
  gem "spork-rails"
  gem "database_cleaner"
  gem "shoulda-matchers"
  gem "poltergeist"
  gem "launchy"
  gem "fuubar"
  gem "simplecov"
  gem "sunspot-rails-tester"
end
PerfectlyNormal commented 10 years ago

Strange…

I made a Rails 3.2 version of the demo app (demo, source), and it works fine for me.

I've had some trouble with turbo-sprockets-rails3 before, both with this gem and others. You might want to make sure it is updated, or try without it and see what happens.

maxbeizer commented 10 years ago

No luck when ripping out turbo-sprockets. Still getting the error from the issue title. I will keep pulling things out until I get down to your example and report back if anything changes. Thanks for helping and for this gem!

maxbeizer commented 10 years ago

I'll close for now and reopen if I ever figure out what the issue is. Thanks!

codeurge commented 9 years ago

I'm actually having the same issue on a Rails 3.2.17 app - it's a rather large app, but I'd be willing to supply what I can to help. I was essentially in the same boat as the author, everything is working great locally, even uploading to S3 is going smooth.

However, when I pushed this into staging (production), the asset isn't available (404): No route matches [GET] "/assets/tinymce/plugins/uploadimage/plugin.js"

I am sorry for re-opening this bug, but I thought it would be important for others to know how I was able to resolve this for now. I had to add the assets to my assets.precompile:

config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
config.assets.precompile += %w( tinymce/plugins/uploadimage/plugin.js tinymce/plugins/uploadimage/langs/en.js )

After that, it seems I'm good to go for now. I am using the = tinymce_assets helper, but that doesn't seem to include the assets for me.

Thanks for the gem, and the beta looks great so far!

maxbeizer commented 9 years ago

@codeurge Thanks for following up and I'm glad it's working for you. Mostly I write to suggest that you bump up your Rails version to 3.2.19 as it fixes security issues.

Sorry @PerfectlyNormal for the non-gem-related comment.

PerfectlyNormal commented 9 years ago

Happy to hear you manage to get it working. I wrote a small note about it in the readme.

Works for me without any such line added, but my pipeline has a thousand tweaks and hacks, so anything could be the cause, and I'm terrified of touching anything.