Questions tagged [button-to]
67 questions
41
votes
2 answers
Rails button_to - applying css class to button
This is silly, but I just can't figure out how to style the input element created by Rails button_to -- and yes, I've read the docs over and over again and tried the samples.
Here's my ERB code:
<%= button_to "Claim", action: "claim", idea_id:…

ezuk
- 3,096
- 3
- 30
- 41
18
votes
7 answers
:confirm in rails not working
I just started coding in ruby on rails and I've been following a guide which is using a more outdated version of rails than I am using. I am using 3.2.12
This is my code:
<%= button_to 'Destroy', product, :method => "delete", :confirm => 'Are you…

jamesdlivesinatree
- 1,016
- 3
- 11
- 36
4
votes
1 answer
Rails button_to using get request when post is specified
So in my rails application I have a button_to on one of my pages. When I click that button on the page, it goes to the appropriate action and does everything I want, BUT: It uses a GET request. When I look in the chrome console under network it…

user1759942
- 1,322
- 4
- 14
- 33
3
votes
1 answer
rails link_to and button_to with bootstrap button class behaves differently
I've following link_to on show article view page,
<%= link_to "Add Pictures",
new_picture_path(article_id: @article.id),
class: "btn btn-small btn-success" %>
This works perfectly by displaying 'link' as a button with the help of "btn"…

Atarang
- 422
- 1
- 6
- 22
3
votes
3 answers
RoR how to get button_to path to /needs/4 instead of /needs.4?
I am still fairly new to RoR and I am trying to delete an object with a button_to delete button.
With the code I wrote though, it gets me to /needs.4 instead of /needs/4 when I try to get it to /needs/:id for the destroy method.
A "need" is created…

mcn
- 45
- 5
3
votes
1 answer
rails, view does line feed for button_to but not link_to
%p
%br
%span.footer_links
= link_to 'Edit', edit_link_path(@link)
= link_to 'Edit', edit_link_path(@link)
= button_to 'Delete', @link, :confirm => 'Are you sure?', :method => :delete
= button_to 'Delete', @link, :confirm => 'Are…

Michael Durrant
- 93,410
- 97
- 333
- 497
2
votes
1 answer
Ruby on Rails: Increase value of object in scaffold with button_to
I have a scaffold that generates a table of basketball teams. I want to implement a button in the table that increases the number of wins for a team and another for the losses.By default, both are set to 0 in the controller. Should I implement a…

Arturo Medina
- 35
- 5
2
votes
1 answer
rails re-enable button_to after downloading file
I'm using button_to in a page for downloading a PDF file.
= button_to "Download Report", evaluation_report_attempt_path, method: :get, class: "btn btn-primary", data: { disable_with: "Downloading..."}
There is no page redirection happening here.…

Mithesh M
- 21
- 2
2
votes
3 answers
Rails: Can I test for the presence of a button_to?
My site had dozens of instances of "link_to". I decided to change most of them to "button_to" for better appearance. The lines of my test that used to check for the presence of those links are no good anymore.
assert_select "a", :href =>…

Jeff Zivkovic
- 547
- 1
- 4
- 20
2
votes
1 answer
rails controller action AND javascript onclick
I am trying to do both: call a controller action and react to onclick with a javascript function. At the moment, I only can do one thing. Trying with
<%= button_to 'Call Action', contoller_action_path, :remote => true,
:method =>…

devynF
- 25
- 3
2
votes
1 answer
Multiple buttons pointing to single Controller Action
I am making an app where user can print a doc in either PDF or JPG format, using wicked-pdf and imgkit respectively.
I have two buttons, one for PDF and other JPG. Is it possible to have these buttons point to same action in controller which here is…

Niyanta
- 473
- 1
- 9
- 15
2
votes
1 answer
rails remote call internal server error 500 in book agile web dev rails 4 - chapter 11
I'm new to rails (my 5th week) and currently I learn with the book "agile web dev with rails 4". I just finished chapter 11 and to my own amusement, I planed to add a remote call to destroy all quantity from a item in the cart. Well, the problem is,…

AdvanceInBeginning
- 99
- 1
- 8
2
votes
3 answers
button_to works only intermittently, and often results in a "no route" error
Added on edit, 2013-02-11:
I should make it clearer that the problem I'm having is not that I can't get the ERB code I write to produce correct HTML code. Rather, it is that my Rails installation sometimes interprets the HTML code correctly, so that…

Teemu Leisti
- 3,750
- 2
- 30
- 39
2
votes
3 answers
Ruby on Rails: How to add additional params to button_to :back?
I'm doing a Rails project for class where a user can enter a search term, the results are displayed (images), then the user can click on an image to get a larger version of it.
On the larger version page, I have a button_to :back.
<%= button_to…

wolf2600
- 565
- 2
- 8
- 17
2
votes
4 answers
HTML content for button_to
I am currently using link_to:
<%= link_to edit_webcast_path(@webcast), :class => 'btn' do %>
Edit Webcast
<% end %>
But I want to do the same with button_to, however button_to must have a first label argument passed…

Undistraction
- 42,754
- 56
- 195
- 331