Skip to content

Instantly share code, notes, and snippets.

@between40and2
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save between40and2/8238764b1e2dd3cfead8 to your computer and use it in GitHub Desktop.
Save between40and2/8238764b1e2dd3cfead8 to your computer and use it in GitHub Desktop.
Rails Plugin and scafford css

Rails Plugin

With my experience with Rails 4.0.5 so far, to my own naivety, I found that the error message displayed in form is different from the normal Rails app. The root cause is that 'scaffold.css' is not included.

Code generated by scaffold

<div class="field">
 <%= f.label :password %><br>
 <%= f.password_field :password %>
</div>
<div>
 <%= f.label :password_confirmation %><br>
 <%= f.password_field :password_confirmation %>
</div>

Code executed

<div class="field">
  <label for="account_password">Password</label><br>
  <input id="account_password" name="account[password]" type="password" />
</div>
<div>
  <div class="field_with_errors"><label for="account_password_confirmation">Password confirmation</label></div><br>
  <div class="field_with_errors"><input id="account_password_confirmation" name="account[password_confirmation]" type="password" /></div>
</div>

Sets of CSS'es

In the case that your app uses N mountable plugins, there are 1+2N sets of assets actully. For each plugin, there are 2, one is in app, the other is in test/dummy/app. Of course, the second one is for testing that your app would not be used. So there will be 1+N sets of assets to be used.

assets defined by plugin, will be used in app (by default?). I have not found so far the way to configure plugin assets to be used or forbidden. Help!

The css related is in plugin's app/assets/scaffold.css . Such as

.field_with_errors {
  padding: 2px;
  background-color: red;
  display: table;
}

Way to heal is to edit application.css to add *= require 'scaffold'

Learning ActiveModel::Errors

J

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment