I am migrating a Rails 2.2.2 project to Rails 3 but I am seeing a lot of 404 errors:
Started GET "/assets/b2b.png" for 172.20.140.52 at 2013-03-11 12:30:24 -0400
Served asset /b2b.png - 404 Not Found (8ms)
ActionController::RoutingError (No route matches [GET] "/assets/b2b.png"):
Started GET "/assets/default.css" for 172.20.140.52 at 2013-03-11 11:57:29 -0400
Served asset /default.css - 404 Not Found (5ms)
ActionController::RoutingError (No route matches [GET] "/assets/default.css"):
In my Rails 2.2.2 project, all of my stylesheets were stored in
/var/www/my_app_directory/public/stylesheets/ so I just moved that over to Rails 3, which I think is the issue.
Where should I put all of my CSS for Rails 3 to be happy?
Thanks
Rails 3 introduced assets pipeline so you should move all stylesheets to
app/assets/stylesheets
and create application.css which should contain:
// require_self
// require_tree .
Related
I am using the DataTables library in my Rails 4.2.1 application. I have manually included all of the assets that are required including 1 js file, 1 css file, and 3 images. The js and css are properly precompiling but the images are not.
Currently the three images are located in vendor/assets/images/<name>.png. They are not precompiling (which after some research is intentional in rails 4.0+) and after attempting all of the fixes I could find on SO I still cannot get these images properly loaded by the asset pipeline. I have tried the following fixes to no avail.
Attempted fixes
Move images to app/assets/images
Add config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif) to config/application.rb
Add config.assets.paths << Rails.root.join("vendor", "assets", "images") to config/application.rb
Errors
The error messages thrown by DataTables js are the following:
GET http://localhost:3000/vendor/assets/images/sort_both.png 404 (Not Found)
GET http://localhost:3000/vendor/assets/images/sort_asc.png 404 (Not Found)
My app worked a few days ago.
I have switched to 'thin' from webrick
now I get
2011-12-28T07:08:53+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/jquery.livequery-6725741b06c676d9173d5056b277caeb.js"):
I saw on other question that they were told to set this to true
config.serve_static_assets = false
but heroku recommends against that.
I have tried both using rake assets:precompile locally and then pushing and also without it and let heroku precompile.
Both give same error
How do I make sure the javascripts are served, compiled and available?
Why is the error occuring?
I'm using rails 3.1.3 on cedar, Latest Thin.
I was able to solve this using the question Rails 3.1 asset precompilation - include all javascript files
so.. problem solved
I am using Fancy box (jquery plugin ) to view video files in my application. I have placed the plugin under vendor -> Javascripts -> javascripts.
but when I run the development server I get the following errors:
Note: I have not modified anything: I just moved the files from my desktop and placed them under vendor/javascript folder
ActionController::RoutingError (No route matches [GET] "/jquery.fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.js"):
Rendered /Users/jayparteek/.rvm/gems/ruby-1.9.2-head#default/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.9ms)
ActionController::RoutingError (No route matches [GET] "/jquery.fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.css"):
Rendered /Users/jayparteek/.rvm/gems/ruby-1.9.2-head#default/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.6ms)
You should use the gem 'fancybox-rails'
we have developed an rails project using rails 3 and mysql, it has images, css and javascript (jquery) and it is working fine in windows xp environment.
But when i migrated the code to ubuntu, the images, css ( applies partially) and javascript (jquery) are not loading. i am running in development mode.
I have included the js and css like this:
<%= stylesheet_link_tag "jquery-one", "ctlCalendar", "application", "jquery.treeview" %>
<%= javascript_include_tag "jquery-1.6.2.min", "jquery.rails", "jquery.treeview"%>
Here the error i am getting:
Started GET "/images/LoginImage.png" for 127.0.0.1 at 2011-08-13 01:02:04 +0900
ActionController::RoutingError (No route matches "/images/LoginImage.png"):
Rendered /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.0ms)
Started GET "/Images/Back_Login.gif" for 127.0.0.1 at 2011-08-13 01:02:05 +0900
ActionController::RoutingError (No route matches "/Images/Back_Login.gif"):
Rendered /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.1ms)
can anyone help me to solve this problem?
Thank You,
Sudhir C.N.
Ubuntu, and other Linux versions, have case-sensitive file names, while Windows XP doesn't.
This means while LoginImage.png and loginimage.png are the same in Windows, they are not the same in Ubuntu. That's probably the cause of your problem.
The same applies to path names – /images and /Images are completely different paths in Linux, so make sure not to mix them up.
Currently i'm developing 2 Rails::Engines 1 blog (for fun) and 1 csv importer and mapper. I made them with enginex and jeweler into a gem. I installed them locally and i included either 1 of them in an empty rails 3.x project and it's working fine!
The thing i want to do know is include both gems in 1 rails 3.x project. This all works doesn't raise any errors but here is the problem.
When i go to my "/blog" routes everything is rendered perfectly. But when i go to my "/csv" route i dont see any layouts. When i look at the development.log i see this:
Started GET "/csv" for 127.0.0.1 at Sun May 01 20:23:19 +0200 2011
Processing by CsvEngine::ImportsController#index as HTML
Rendered /Library/Ruby/Gems/1.8/gems/csv_engine-0.0.1/app/views/csv_engine/imports/index.html.erb within layouts/application (0.8ms)
Completed 200 OK in 24ms (Views: 23.1ms | ActiveRecord: 0.0ms)
This all looks fine, but i dont see any of my html. But when i put a <%= raise "hell %> inside my index.html.erb it gets raised. So i'm baffled here, both my engines work. All my rails logic works but i dont see my html inside the index.html.erb.
The strangest thing is when i include "csv_engine" gem without the blog gem in a empty rails 3 app everything works fine and i get the html views.
I even tried overwriting the views from within my empty host app e.g. app/views/csv_engine/imports/index.html.erb with some other html in it but this also doesnt work.
Does anyone has any idea what this could be?