New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `admin_dialogs_path' for #<Module:... on Heroku #1751

Closed
julesce opened this Issue Jun 13, 2012 · 32 comments

Comments

Projects
None yet
7 participants
@julesce

julesce commented Jun 13, 2012

Hi guys,

I'm getting the following error when deploying any 2.0.4 or 2.0.5 refinerycms apps to Heroku:

-----> Preparing app for Rails asset pipeline
   Running: rake assets:precompile
   rake aborted!
   undefined method `admin_dialogs_path' for #<Module:0x00000006d06708>
   (in /tmp/build_13ex2hfe5y1g5/vendor/bundle/ruby/1.9.1/gems/refinerycms-core-2.0.5/app/assets/javascripts/refinery/boot_wym.js.erb)

So for now I'm just sticking with 2.0.3... is there a setting that needs to be changed from the way it works in 2.0.3?

Thanks!

James

@parndt

This comment has been minimized.

Member

parndt commented Jun 13, 2012

Note to @ugisozols @robyurkowski we need a test to simulate running a task with no database or a bad database configuration as this is how you simulate precompile

@ugisozols

This comment has been minimized.

Member

ugisozols commented Jun 13, 2012

Why is this happening? I just deployed vanilla 2.0.5 app without a hiccup...

@julesce

This comment has been minimized.

julesce commented Jun 13, 2012

Hmmm... I've got an app that was generated in 2.0.3, and I've just upgraded the version to 2.0.4/5 by updating the gem version number and then running 'bundle update refinerycms'...

My application.rb looks like this:

if defined?(Bundler)  
  # If you want your assets lazily compiled in production, use this line
  Bundler.require(:default, :assets, Rails.env)
end

And then lower down:

# Make sure it works on Heroku
config.assets.initialize_on_precompile = false

Do these need to be changed? Or is there a command that needs to be run when upgrading from 2.0.3 to 2.0.5?

Thanks!

@ugisozols

This comment has been minimized.

Member

ugisozols commented Jun 13, 2012

I'm guessing here but I think the issue lies in:

# If you want your assets lazily compiled in production, use this line
Bundler.require(:default, :assets, Rails.env)

Try changing it to:

Bundler.require(*Rails.groups(:assets => %w(development test)))

...and try to deploy.

@julesce

This comment has been minimized.

julesce commented Jun 13, 2012

So you're saying that I need to precompile my assets before pushing to Heroku?

Cos that is what the comment above that line says:

# If you precompile assets before deploying to production, use this line
#Bundler.require(*Rails.groups(:assets => %w(development test)))

What would be the best way to do this? Is there an automated way to do this? I'd prefer to not have to manually precompile before each push to Heroku... kinda like the way it used to work with 2.0.3 :-)

@ugisozols

This comment has been minimized.

Member

ugisozols commented Jun 13, 2012

I didn't have to precompile anything manually as heroku took care of it so just comment out that line and try to push to heroku.

@julesce

This comment has been minimized.

julesce commented Jun 13, 2012

No luck for me - I've changed that line as recommended but still getting the same error I'm afraid.

@ugisozols

This comment has been minimized.

Member

ugisozols commented Jun 13, 2012

I'm out of ideas then... sorry.

@julesce

This comment has been minimized.

julesce commented Jun 13, 2012

No problemo - I'll try and take a closer look at what changed from 2.0.3 -> 2.0.4 to see if I can spot the problem. Thanks for your help though!

@parndt

This comment has been minimized.

Member

parndt commented Jun 13, 2012

You need to set

config.assets.initialize_on_precompile = true

@julesce

This comment has been minimized.

julesce commented Jun 14, 2012

Ok, I've changed that setting (along with both versions of the Bundler.require(etc...) - and get the following error on both:

-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       rake aborted!
       could not connect to server: Connection refused
       Is the server running on host "127.0.0.1" and accepting
       TCP/IP connections on port 5432?

Sorry I know I'm doing something silly here, but once we solve this I'll update the docs accordingly.

@parndt

This comment has been minimized.

Member

parndt commented Jun 14, 2012

As a workaround for now you may want to precompile locally if you just want
to get deploys working. Unfortunately it could be a number of things.

@ugisozols

This comment has been minimized.

Member

ugisozols commented Jun 22, 2012

@julesce did you resolve this issue?

@julesce

This comment has been minimized.

julesce commented Jun 25, 2012

Haven't had a chance to take a closer look yet sadly. Deadlines suck :p

@nicholasjhenry

This comment has been minimized.

nicholasjhenry commented Jul 7, 2012

Deploying to Heroku: I started getting this error after adding PageImages engines on a bare install. First I received the same error as @julesce:

Preparing app for Rails asset pipeline
unning: rake assets:precompile
rake aborted!
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting

as instructed by Heroku, I adjusted the assets config option:

https://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar

config.assets.initialize_on_precompile = false

Changing this line I received the following error:

undefined method `admin_dialogs_path' for #<Module:0x000000033038d0>

I did not know about the line in the application.rb so I switch that and deployed, same error unfortunately.

I reverted all my changes and opted to use Heroku's user_env_compile plugin which resolved the issue:

https://devcenter.heroku.com/articles/labs-user-env-compile

@harley

This comment has been minimized.

Contributor

harley commented Jul 8, 2012

i also run into this problem ended up with the same approach as @nicholasjhenry who did a great job explaining why!

in short, the problem is because with config.asset.initialize_on_precompile = false, Rails app is only partially loaded. as a result, Refinery::Core::Engine.routes.url_helpers does not recognize admin_dialogs_path at the point of precompilation. two days to solve this:

  1. make deployment to heroku works with config.asset.initialize_on_precompile = true (default) by using user_nav_compile
  2. override app/assets/javascripts/refinery/boot_wym.js.erb in your app and replace Refinery::Core::Engine.routes.url_helpers.admin_dialogs_path with something else -- this approach is brittle because there may be more occurrences like these, unless refinerycms fixes this and decides to support making precompilation work with config.asset.initialize_on_precompile -- probably not worth the effort
@parndt

This comment has been minimized.

Member

parndt commented Jul 8, 2012

We actually chose to work with = true rather than with false so that
assets can use erb.

@magpieuk

This comment has been minimized.

Contributor

magpieuk commented Jul 13, 2012

looks like this is due to the following change https://github.com/resolve/refinerycms/pull/1565/files

The rails guide (http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets) says the following:

If you set config.assets.initialize_on_precompile to false, be sure to test rake assets:precompile locally before deploying. It may expose bugs where your assets reference application objects or methods, since those are still in scope in development mode regardless of the value of this flag.

@parndt

This comment has been minimized.

Member

parndt commented Jul 13, 2012

Hi Lee!! That makes sense - that is why Refinery likes the config
setting to be = true so that the environment initialises and the path
exists. This is necessary for many reasons including being mounted to
custom locations and hosting using sub URIs.

Any suggestions for how else this could be achieved?

@magpieuk

This comment has been minimized.

Contributor

magpieuk commented Jul 13, 2012

What you doing up? Not sure how else but looking around at present. We are going to hack the gem locally so that we can then do a precompile and then deploy to heroku.

@parndt

This comment has been minimized.

Member

parndt commented Jul 13, 2012

Cool I'm falling asleep so I hope you find a solution. Thanks!

@magpieuk

This comment has been minimized.

Contributor

magpieuk commented Jul 13, 2012

@harley

This comment has been minimized.

Contributor

harley commented Jul 13, 2012

thanks @magpieuk for adding the notes on custom loading of the initializers. that's pretty cool!

at the end of the day though, i find initialize_on_precompile = false to be of little use and causes more troubles than it's worth. i think it barely makes any difference to the precompilation time so i dont see any benefit.

worse, when using it, one should "be sure to test rake assets:precompile locally before deploying", but precompilation is very slow (that's another issue!) so it hurts productivity having to precompile locally. heroku labs' user_nav_compile seems to be the best bet now and i think Refinery is right in using assuming config = true approach

perhaps it should be mentioned in the guide https://github.com/resolve/refinerycms/blob/master/doc/guides/7%20-%20Hosting%20and%20Deployment/1%20-%20Heroku.textile -- @parndt i can add to it if you agree? and if so, is that file the right one to add to?

@parndt

This comment has been minimized.

Member

parndt commented Jul 13, 2012

Sure that makes sense to me

@magpieuk

This comment has been minimized.

Contributor

magpieuk commented Jul 14, 2012

Does the user_nav_compile work?

Sent from my iPhone

On 13 Jul 2012, at 17:53, Harley Trungreply@reply.github.com wrote:

thanks @magpieuk for adding the notes on custom loading of the initializers. that's pretty cool!

at the end of the day though, i find initialize_on_precompile = false to be of little use and causes more troubles than it's worth. i think it barely makes any difference to the precompilation time so i dont see any benefit.

worse, when using it, one should "be sure to test rake assets:precompile locally before deploying", but precompilation is very slow (that's another issue!) so it hurts productivity having to precompile locally. heroku labs' user_nav_compile seems to be the best bet now and i think Refinery is right in using assuming config = true approach

perhaps it should be mentioned in the guide https://github.com/resolve/refinerycms/blob/master/doc/guides/7%20-%20Hosting%20and%20Deployment/1%20-%20Heroku.textile -- @parndt i can add to it if you agree? and if so, is that file the right one to add to?


Reply to this email directly or view it on GitHub:
https://github.com/resolve/refinerycms/issues/1751#issuecomment-6968773

@harley

This comment has been minimized.

Contributor

harley commented Jul 14, 2012

yeah it still works for me so far (used to use user_nav_compile to set RUBY_VERSION as 1.9.3 before heroku understood the bundler syntax ruby '1.9.3' in Gemfile as well)

@parndt

This comment has been minimized.

Member

parndt commented Jul 14, 2012

@nicholasjhenry

This comment has been minimized.

nicholasjhenry commented Jul 14, 2012

@harley

This comment has been minimized.

Contributor

harley commented Jul 14, 2012

oops so sorry user_env_compile, NOT user_nav_compile -- thanks for catching it

@robyurkowski

This comment has been minimized.

Contributor

robyurkowski commented Jul 16, 2012

Okay, can we agree, at least for the time being, that doing user_env_compile is the way to go here? I'm not really sure that I love the solution, but it's at least the least kludgy without requiring us to keep erb from our JS files, which is somewhat of an impossibility at this point.

Thoughts, @parndt, @ugisozols, @gogogarrett?

@parndt

This comment has been minimized.

Member

parndt commented Jul 16, 2012

The solution will be to add this to the Heroku guide yes.

@robyurkowski

This comment has been minimized.

Contributor

robyurkowski commented Jul 16, 2012

Working on it right at this moment.

On 2012-07-16, at 12:13 AM, Philip Arndt wrote:

The solution will be to add this to the Heroku guide yes.


Reply to this email directly or view it on GitHub:
https://github.com/resolve/refinerycms/issues/1751#issuecomment-6998155

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment