Hello, (Rails 4, Ruby 2) I am trying to deploy my first rails app in a production environment, but cannot get the assets to load. The site is hosted on Webfaction, they advise to create a "static app" to serve the assets which I have done. But I don''t understand how my rails app then knows about the static app. At the moment, in production inside the head it prints out... "/stylesheets/application.css" "/javascripts/application.js" But I want it to be "/assets/stylesheets/application.css". Any help or advise would be most welcome. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1d480a40-e9d2-47b6-9d96-7215aa1ab0f5%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
you should try this command rake assets:precompile RAILS_ENV=development On Sat, Oct 12, 2013 at 7:45 PM, Phillip <phil13b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > (Rails 4, Ruby 2) > > I am trying to deploy my first rails app in a production environment, but > cannot get the assets to load. The site is hosted on Webfaction, they > advise to create a "static app" to serve the assets which I have done. But > I don''t understand how my rails app then knows about the static app. > > At the moment, in production inside the head it prints out... > > "/stylesheets/application.css" > "/javascripts/application.js" > > But I want it to be "/assets/stylesheets/application.css". > > Any help or advise would be most welcome. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/1d480a40-e9d2-47b6-9d96-7215aa1ab0f5%40googlegroups.com > . > For more options, visit https://groups.google.com/groups/opt_out. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAJgx-dhe33QHaqUwv3zphznGSZBFS0iP-Abw0yOHpnNYoOaF7A%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
On Sat, Oct 12, 2013 at 9:45 AM, Phillip <phil13b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am trying to deploy my first rails app in a production environment, but > cannot get the assets to load. The site is hosted on Webfaction, they advise > to create a "static app" to serve the assets which I have done. But I don''t > understand how my rails app then knows about the static app.I don''t even want to know what they are talking about or implying because it sounds wrong. By default in production on a Rails 4 application it prefers you to pass asset serving up higher in the chain because it will be much quicker for nginx/apache to serve the app than it will be for Rails to serve it especially considering you have to proxy to rails who then has to send it back and then it gets served. This means that when you build a new app you need to make sure you have a proper root set (or a sub-domain) that can lead to the public folder and each time you deploy you need to do `rake assets:precompile` to get your assets to work. If you do not wish this to be the case then set your production.rb to serve static assets and go on about your way as you will not need to have nginx/apache care about it. At that point your Rails application will know the asset path and you will have access to public/assets/$(name)-$(hash).$(ext). -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAM5XQnyQH3Hg9DqH2pewtGNSbJxU-Wwr9h7LVZfjjBpSYXY0wQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Thanks Jordon, that''s giving me a few things to go on. (Off to investigate...) On Saturday, October 12, 2013 4:15:18 PM UTC+1, Jordon Bedwell wrote:> > On Sat, Oct 12, 2013 at 9:45 AM, Phillip <phi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> > wrote: > > I am trying to deploy my first rails app in a production environment, > but > > cannot get the assets to load. The site is hosted on Webfaction, they > advise > > to create a "static app" to serve the assets which I have done. But I > don''t > > understand how my rails app then knows about the static app. > > I don''t even want to know what they are talking about or implying > because it sounds wrong. By default in production on a Rails 4 > application it prefers you to pass asset serving up higher in the > chain because it will be much quicker for nginx/apache to serve the > app than it will be for Rails to serve it especially considering you > have to proxy to rails who then has to send it back and then it gets > served. > > This means that when you build a new app you need to make sure you > have a proper root set (or a sub-domain) that can lead to the public > folder and each time you deploy you need to do `rake > assets:precompile` to get your assets to work. If you do not wish > this to be the case then set your production.rb to serve static assets > and go on about your way as you will not need to have nginx/apache > care about it. > > At that point your Rails application will know the asset path and you > will have access to public/assets/$(name)-$(hash).$(ext). >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f4e7f260-ec2c-4932-93f7-9ee8d4f5eed0%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Reasonably Related Threads
- rake assets:precompile issue with JS and stylesheets files with similar name
- rake precompile:assets throwing error
- My SCSS compiled CSS lacks "/assets" in the generated urls
- can't compile assets on prod due to asset_host config && SSL requirement
- how to change theme in rails 3.2.7