I’m new to Rails, so bear with me.
I have a view file called new.html.erb that renders a form (_form.html.erb) that uses a nested form (_traveler.form.erb). These are located in the app/views/traveling_parties directory. I’m trying to use CSS to style this form.
I’ve seen the question ” Where do you put CSS files in a rails app directory? “, so I stuck my css file (newgame.css) in public/stylesheets and put the following tag at the top of my new.html.erb file:
<head>
<%= stylesheet_form_tag "newgame" %>
</head>
In my CSS file, I have a test ID:
#test
{
background: #000;
height: 100px;
width: 100px;
}
And I applied this to a div in my new.html.erb file
But it doesn’t seem to do anything… Is there anything I’m doing blatantly wrong? Is there any other information I can provide?
you should check http://railscasts.com/ for episodes about views and layouts (e.g. search there)
The answer depends on which version of Rails you are using.
In general you could have multiple layouts in a Rails application.
If you have just one layout, then your CSS file will be in the default location for your Rails version.
e.g. (assuming you are using SCSS)
public/stylesheets/application.scss in Rails 2.x
app/stylesheets/application.scss in Rails 3.x
Check also this RailsGuide:
http://guides.rubyonrails.org/layouts_and_rendering.html
Check these two RailsCasts: (in particular in regards to the Asset Pipeline)
http://railscasts.com/episodes/279-understanding-the-asset-pipeline
http://railscasts.com/episodes/282-upgrading-to-rails-3-1