Displaying 20 results from an estimated 578 matches for "respond_to".
2006 Jun 24
5
request.xhr? vs. respond_to
Searched around this forum, but didn''t find an answer for this question.
Can you help this newbie understand any overlap and/or difference
between request.xhr? and respond_to?
If request.xhr? is true, should I expect it wants.js below?
respond_to do |wants|
wants.html { redirect_to(person_list_url) }
wants.js
wants.xml { render :xml => @person.to_xml(:include => @company) }
end
Is it fair to say the functionality of respond_to a super...
2006 Apr 08
2
respond_to causes DoubleRenderError?
...h straight http requests, but
wanted to add support for ajax requests. I thought this would be a
simple matter of replacing all of my "redirect_to <blah> and return
false" calls with something like "redirect <blah> and return false",
where the redirect method wraps a respond_to block. For example:
def redirect(url)
respond_to do |wants|
wants.html { redirect_to url }
wants.js { render :update do |page| page.redirect_to url end }
end
end
However, this causes a DRE when I deployed it on my FCGI production
server. In fact, removing the w...
2008 Apr 20
1
Why is respond_to always rending the RXML view?
I''m having a problem in Rails 2 where respond_to is always rendering the
RXML view even in the HTML rendering response. Can anyone tell me why
this might be happening? Here''s a code snippet:
respond_to do |accepts|
accepts.html
accepts.xml { render :action => ''show.rxml'', :layout => false}
end
If I change...
2007 Apr 26
2
assert_select with respond_to JS or xhr?
Hi everyone,
I am a bit confused with xhr? and respond_to.
I have the folloing code in my view to update the ''emails'' ID
link_to_remote(image_tag("refresh"), :update => "emails",
:url => { :action => "list_emails" })
in the controller side i have somthing like :
[..]
respond_to do |type|...
2009 Aug 16
5
any help with captcha in my comments ?
..., expecting kEND
else
^):
this is my code:
class CommentsController < ApplicationController
include SimpleCaptcha::ControllerHelpers
def create
if simple_captcha_valid?
@post = Post.find(params[:post_id])
@comment = @post.comments.create!(params[:comment])
respond_to do |format|
format.html { redirect_to @post }
format.js
else
flash[:notice] = "please right down the image verification"
end
end
end
end
any suggestions ?
--
Posted via http://www.ruby-forum.com/.
2006 Aug 14
1
respond_to? in acts_as_ferret results
acts_as_ferret''s search results use #method_missing to forward method
calls to the underlying result object. However, those methods are
represented in #respond_to?
Here''s a simple fix for that:
module FerretMixin
module Acts
module ARFerret
class SearchResults
def respond_to?(name)
self.methods.include?(name) || @results.respond_to?(name)
end
end
end
end
end
thanks
-ryan
2006 Aug 30
10
respond_to not detecting JS turned on. form_to_remote problem?
I''m trying to use respond_to to redirect visitors who have JS turned off to a different page. The problem I''m having is that respond_to is sending *everybody* there. It''s not recognizing that JS is turned on in the browser. The wanted_html.rhtml file below is rendered whether I''ve got JS turned on...
2007 May 28
2
Rails, respond_to? over anonymous module (extend has_many).
...end
end
# validations goes here
validates_presence_of :title
validates_uniqueness_of :title
# code after this point
end
==
Now, running a simple spec like this:
describe Playlist do
fixtures :playlists
before(:each) do
@list = Playlist.new
end
it { @list.assets.should respond_to(:<<) }
it { @list.assets.should respond_to(:delete_at) }
it { @list.assets.should respond_to(:order) }
it { @list.assets.should respond_to(:reorder) }
end
==
Only #order and #reorder report errors:
1)
''Playlist should respond to #order'' FAILED
expected target to res...
2010 Nov 08
7
Webrick Failing with Illegal Instruction
...and then
added a route to routes.rb with "resources :lessons"
Now, when i go to /lessons, Webrick fails with "Illegal instruction"
The controller function getting hit is lessons#index, and looks like
this:
# GET /lessons
# GET /lessons.xml
def index
@lessons = Lesson.all
respond_to do |format|
format.html index.html.erb
format.xml { render :xml => @lessons }
end
end
If i comment out the respond_to section, the index page renders fine
with no crashing. I have no idea what I could have done to make it begin
to crash with respond_to? This is the first time i'...
2010 Aug 21
1
Rendering a different Javascript file in respond_to
Hi everyone, I am stuck in an (apparently) simple problem.
In my event_controller I have the i_like_it action:
def i_like_it
@event = Event.find(params[:id])
... # logic
respond_to do |format|
format.js
end
end
In my case "i_like_it" is called with :method => PUT (it is an Ajax
call, "i_like_it.js.erb" will be returned as a script and it wil be
executed on the browser.)
I would like render a Javascript file with a different name (not
i_lik...
2008 Mar 18
4
respond_to formats, fbml and fbjs
In my controllers I have a respond_to block for both fbml and fbjs.
I created the fbjs mime type in environment.rb:
Mime::Type.register "application/javascript", :fbjs
However, even if I specify fbjs in a parameter name format during AJAX
post requests, it is being overwritten by Rails or Facebooker as FBML.
I confirmed thi...
2006 Jun 28
2
respond_to and Accept headers
After reading:
<http://www.loudthinking.com/arc/000572.html>
I''m trying to experiment with respond_to in order to not repeat myself
and create atom feeds out of a "browse" view.
In application controller I created a before filter that checks for the
extension of the current url and changes the accept header:
[code]
def check_headers
@headers["Accept"] = "applicati...
2007 Oct 16
6
respond_to API
I''ll probably do my respond_to API rewrite, as discussed here:
http://rubyforge.org/pipermail/merb-devel/2007-September/000275.html
sometime this week, unless someone has come up with a better API.
I''ll also work in http://merb.devjavu.com/ticket/227 at the same time.
Any serious objections?
2006 Mar 22
1
undefined method `respond_to'' when using Exception Notifier Plugin
I''m trying to use the exception notifier plugin and I''m getting this error
message:
NoMethodError (undefined method `respond_to'' for
#<Adm::PeriodController:0xb74c9804>):
/vendor/plugins/exception_notification/lib/exception_notifiable.rb:64:in
`render_500''
/vendor/plugins/exception_notification/lib/exception_notifiable.rb:76:in
`rescue_action_in_public''
Any suggestions? I suspect th...
2012 Feb 20
1
respond_to format.json not being called
Hi all,
I''m submitting a form using jQuery, but in the respond_to block only the
format.html action is called.
This is the javascrip:
send_button.on(''click'', function(){
var form = $(this).closest(''.modal'').find(''form'');
$.post(''/messages'', form.serialize(),
function(data, status,...
2012 May 08
1
One to many relationships
...{"professor_id"=>"1"}
here are the codes for two controllers and index page--
class ProfessorsController < ApplicationController
# GET /professors
# GET /professors.json
def index
@professors = Professor.all
@rate_professors=RateProfessor.order(:lname)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @professors }
end
end
# GET /professors/1
# GET /professors/1.json
def show
@professor = Professor.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { ren...
2006 Jun 08
0
custom mime types for respond_to
Is there a way to add a mime type of my own to respond_to ?
There''s html, xml, js, ical etc ...
But I want to be able to respond_to Excel.
Excel has the following content-type header:
application/vnd.ms-excel
I want to use the new ?format=xml querystring parameters that respond_to
can respond to.
So I want to pass in ?format=xsl or ?format=...
2006 Nov 23
2
Some tips for testing respond_to block and making controller tests work with simply_helpful
Hi,
Here''s two blog posts for those that need to test respond_to blocks
and/or are currently using simply_helpful extensively.
http://blog.methodmissing.com/2006/11/22/testing-different-content-
types-with-rspec
http://blog.methodmissing.com/2006/11/23/using-simply_helpful-with-
rspec-controller-tests
- Lourens
2008 Jun 24
2
wrong number of arguments (1 for 0) when using respond_to?
...39; ).
gsub( /\ on\ /, ''-'' ).
gsub( /[^a-zA-Z0-9\-]/, ''-'' ).
gsub( /[\-]+/, ''-'' ).
gsub( /[\-]$/, '''' ).
gsub( /^[\-]/, '''' ) if model.respond_to?( :path )
end
end
end
class ActiveRecord::Base
include Pathmaker
end
wrong number of arguments (1 for 0)
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/attribute_methods.rb:102:in
`sum''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/act...
2006 Oct 12
6
BackgrounDRb newbie stuck at first base. Fresh pair of eyes needed
...puts args[:message]
get_new_ids(args)
end
def get_new_ids(args)
....
end
end|
However, I get NoMethodError (undefined method `ids_retrieved'' for
#<ScrapeWorker:0x2a678b8>)
Set up a quick unit test, and not surprisingly fails on first respond_to
| def test_should_respond_to_progress_message_and_hse_notices_retrieved
MiddleMan.new_worker(:class => :scrape_worker, :args =>
{:message => "Uh -Oh"}, :job_key => :test_scraper, :ttl => 5)
s = MiddleMan[:test_scraper]
assert s.respond_to?...