TomDogg
TomDogg

Reputation: 3940

HTML (or Rails) button code issue

I'm struggling with the following problem: What's the correct HTML (and/or Rails) code for

Basically, the button should work exactly like a hyperlink.

Thanks for your help!

Tom

Upvotes: 2

Views: 762

Answers (2)

John Glass
John Glass

Reputation: 368

Old question, but for teh Googlez I have a non-JS solution. You can extract the button to a helper method, and then return the html for the button with the link generated by url_for. Use a dummy button as a link and you won't have to worry about doing something fancy to style the button.

def back_button
  target_url = url_for :controller => :users, :action => :new
  "<a href=#{target_url} style='text-decoration:none;'><button type='button'>&lt;&lt; Back</button></a>"
end

Upvotes: 1

coder_tim
coder_tim

Reputation: 1720

You might try the "button_to" tag: Rails API

Upvotes: 0

Related Questions