4

I am creating a custom CSS stylesheet for a Rails 3 application.

Is there a list anywhere of the CSS styles that Rails relies upon? So far I have found:

  • #notice
  • #error_explanation
  • .field_with_errors

Many thanks.

2 Answers 2

6
+50

The css for the flash-messages you can choose yourself, as they are normally defined in application.html.erb (there is no default definition for flash-messages in rails 3).

For form-styling i would recommend using a gem like formtastic, which not only greatly simplifies making forms, but also provides a standard css file. So all needed tags are then known (and can be overwritten if needed).

If on the other hand you are looking at ways to get your complete layout started quickly, you might want to checkout web-app-theme or activo (which is even more complete).

Sign up to request clarification or add additional context in comments.

Comments

1

A fresh Rails 3 app will not require any specific CSS class/id styles beyond the three you just mentioned, which is why no default stylesheet is generated until you start scaffolding.

If you run script/rails generate scaffold MyModel it will create a stylesheet called scaffold.css which the generated views will rely upon.

1 Comment

Rails also relies on these styles when scaffolding isn't used. For example, if I create a view with a form_for and add some validation to the model, a failed validation results in Rails changing the class of the form fields to field_with_errors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.