-2

2020 update: This is an old post that was closed due to it being unclear. I think what I was looking for was how to add !important to CSS attributes in HAML.

I have an issue with my Rails app. I have this code:

= simple_form_for @post, html: { class: "newpost"}  do |f|
= f.input :title
= f.input :content
= f.submit :submit

It works but dosent look to good. And i have tried to look for answers and I found that you can add this code:

= f.input :content, class: "name_of_class"

Witch does nothing. I've been looking for answers for many houers now.

Thanks.

PS: Also I'm using HAML and Rails 4

EDIT: Here is a picture of how it's looking: enter image description here

And when I add CSS in Chrome is looks just like I want it:

enter image description here

But if i try to add the CSS in the code nothing happens.

FCD
  • 51
  • 2
  • 9
  • if it doesn't look too good, set it to a variable in the view helper. `def classy; html: {class: "newpost"};end` Then in the view your form can be 'classy' : simple_form_for @post, classy do |f| – Andy Gauge Dec 20 '15 at 15:04
  • Possible duplicate of [How to set inline style for element in HAML](http://stackoverflow.com/questions/8090010/how-to-set-inline-style-for-element-in-haml) – Sheepy Dec 21 '15 at 04:49

1 Answers1

2

Try to remove class newpost from the form and put the form in a div with your newpost class. I prefer to put the fields in divs and change input styling from sass.

Ruby Doggy
  • 109
  • 5