Questions tagged [respond-to]
112 questions
1
vote
0 answers
Respond to volume buttons when phone is locked
I wrote an app which starts record audio in response to holding volume up button on phone or headphone, I'm doing it inside dispatchKeyEvent method and it's fine
Problem is, I want to do it when the phone is locked in my pocket, I want to just hold…

Ali Molaei
- 396
- 2
- 13
1
vote
1 answer
How to make a speicific text value respond with different text
I'm trying to get specific value back when I write "h" but it won't, and I don't know why. I have tried searching for the problem but could not find the solution, I don't know if I am just being dumb.

Crist
- 13
- 2
1
vote
1 answer
Controller changes format on variables when publishing
I am a newbie to ROR but catching on quickly. I have been working on this problem for a couple of hours now and it seems like a bug. I does not make any sense.
I have a database with the following migration:
class CreateWebsites <…

Christoffer
- 11
- 2
1
vote
1 answer
ActionController::UnknownFormat When using respond_to do |format| in rails 5 app
I'm trying to render pages in a div on a profiles/show.html.erb to make it dynamic.
I'm constantly getting this error. ActionController::UnknownFormat
for this line in my profiles_controller.rb
def show
respond_to do |format|
format.js…

codegirl
- 377
- 1
- 5
- 18
1
vote
1 answer
How do I pass layout false inside respond_to block in Rails?
I'm trying to figure out how to make this work. Here is my code, which is not working right now:
respond_with(@addresses) do |format|
format.json {render :json=>@addresses, :layout=>false}
end

picardo
- 24,530
- 33
- 104
- 151
1
vote
1 answer
override to_xml to limit fields returned
using ruby 1.9.2 and rails 3, i would like to limit the fields returned when a record is accessed as json or xml (the only two formats allowed).
this very useful post introduced me to respond_with and i found somewhere online that a nice way to…

jay
- 602
- 5
- 14
1
vote
1 answer
Using Prototype, is it possible "redirect_to" avoiding to process the full "js.rjs" code?
In *user_controller.rb* file I have this code:
respond_to do |format|
if test = true
format.js
else
format.js { @yo = true }
end
end
In update.js.rjs file I have this code
page.redirect_to :action => "index" if @yo ==…

user502052
- 14,803
- 30
- 109
- 188
1
vote
2 answers
Missing Template Error in Rails Exporting XLS files
export_excel/app/controllers/products/products_controller.rb
class ProductsController < ApplicationController
def index
@products = Product.order(:name)
respond_to do |format|
format.html
format.csv { send_data @products.to_csv…

Bret
- 23
- 4
1
vote
2 answers
Rails route for non-resource for csv
I have a method called "revisions", and I want to be able use the same logic but output to csv. I think I'd like to use the FasterCSV gem. What I need is to what to add to my routes in order to get a route for both the html and the csv outputs. …

Mr Mikkél
- 2,577
- 4
- 34
- 52
1
vote
1 answer
respondToSelector / performSelector with parameter from a string in Swift 3
I have to call method of a class. This method potentially exists or not.
I'm looking for a solution from 2 hours.
The following works without parameter sayHello()
I have the class :
class myClass: NSObject {
func say(something:String){
…

Damien Romito
- 9,801
- 13
- 66
- 84
1
vote
0 answers
Poltergeist and phantom render partial with respond_to in controller
I have a problem executing my rails app feature files headless. I use phantom as webkit and poltergeist as javascript driver.
My feature starts like this:
@javascript
Scenario: Create a customer
Given I am on the "/customers" page
When I…

mahu
- 297
- 1
- 3
- 14
1
vote
1 answer
respond_to and service objects
I'm currently using the docx_replace gem to automate the insertion of data into a set of documents. The gem is pretty straightforward; basically it runs in a special method within your rails controller like so (quoting from the documentation):
def…

neanderslob
- 2,633
- 6
- 40
- 82
1
vote
2 answers
respond_to generate 2 or more pdfs
I'm using rails and prawn pdf to generate report in pdf format
I would like to ask is it possible to generate 2 or more pdf documents from one controller (I'm using respond_to to generate pdf)
below is currently my controller that can generate only…

widjajayd
- 6,090
- 4
- 30
- 41
1
vote
1 answer
using respond_to format.js to replace the content of a textarea on rails
I have some saved text in my create controller. If it's not stressful, I'd like it to populate a textarea on the page with the saved text along with displaying the error message fields (which is what's already happening). I've used things like…

V_H
- 1,793
- 3
- 34
- 59
1
vote
1 answer
jQuery Mobile breaks Rails respond_to when using UJS remote links accept headers
I'm converting our Rails 3 web app to use jQuery mobile, and I'm having problems with "remote" links.
I have the following link:
= link_to "Text", foo_url, :method => :put, :remote => true
Which, on the server, I'm handling like this:
respond_to do…

Daniel Magliola
- 30,898
- 61
- 164
- 243