ActionController::RoutingError for stylesheet in Rails 3
I was tring out below scenario:
Approach 1: Created an resource using rails scaffold, coded all the functionality i.e. index, new, edit and delete functionality - everything is working fine.
Approach 2: Tried to create manually the controller and views for the same functionality with different name for the model created in approach 1. The functionality is working fine.
But i get an RoutingError as:
Started GET "/userwebmgmts/stylesheets/ctlCalendar.css" for 127.0.0.1 at 2011-08-29 17:08:37 +0530
ActionController::Rout开发者_如何学编程ingError (No route matches "/userwebmgmts/stylesheets/ctlCalendar.css"):
In Route.rb file:
added the entry for the newly created controller/view as: get "userwebmgmts/index"
Can anyone help tell why i am getting the error for the controller created manually and not getting the error for the resources created using scaffold?
Thanks, Sudhir C.N.
This is just a shot in the dark from the information you provided but...
Rails routes work in an order first a rack application checks the /public/
folder in the root of your application. If there is a matching file then it will load that.
Rails 3.1
If not it will load up the assets folder and create the pipe line and then check the application.css and application.js
Then it will load up the routes file and start ticking though your routes
If no route matches then you will get an exception thrown.
Your Problem
Your problem probably comes from the fact that your css is in the wrong place
With your file structure
/userwebmgmts/stylesheets/ctlCalendar.css
You should have a link in the page header that looks like this
<link rel="stylesheet" href="/userwebmgmts/stylesheets/ctlCalendar.css" type="text/css" media="screen" title="no title" charset="utf-8">
And the file should be located at
/public/userwebmgmts/stylesheets/ctlCalendar.css
精彩评论