Rails tip #2 How to add css class on rails form


At times its required to make pretty . Forms can be created using form_for or form_tag

To add css class to form_for

  form_for @user, :html=>{:class=> "foo"}

To add css class to form_tag

  form_tag({:action => 'new',...}, {:class => 'my_form'}) do

Happy Coding !!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s