Suraj Suraj - 6 months ago 11
HTML Question

Make a link as a button in rails spree

I am working on a rails spree app.

I want to give my link work as a button. Here's how the link looks.

<%= link_to Spree.t(:forgot_password), spree.recover_password_path %>

How do I make this as Button and add some classes to that button?


If you want to generate an HTML button, instead of a hyperlink then change your link_to to button_to:

<%= button_to Spree.t(:forgot_password), spree.recover_password_path %>

This will generate a form with a single button in it that would take user to a given URL.

However, if you want to simply style your link as a button, then use CSS. The CSS rules will depend on your style. So, just Google and pick a style that fits your needs.

If your template is using Twitter Bootstrap, you can simply add btn and btn-* classes to style it as a button.

<%= link_to Spree.t(:forgot_password), spree.recover_password_path, class: 'btn btn-default' %>