Displaying 20 results from an estimated 3000 matches similar to: "transition form respond_to to provides"
2007 Sep 20
11
Proposed API change for respond_to
Ez (or someone) asked on #merb tonight whether respond_to was the
right API for
what it does. After some discussion and pasties, I offer the
following proposed
API for content negotiation and response format selection:
First, what does respond_to do right now? I see at as performing 3
distinct
operations:
1. parse params[:format] and the accepts header to find out what
format the
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
2007 Jul 29
2
fcgi?
Hi,
I''ve been looking for a light weight alternative to rails for a few
small projects, and just came across merb, which looks perfect. The
only issue is that merb seems to be tied to mongrel, and I have to
deploy to our internal infrastructure which uses FastCGI.
How difficult would it be for me to modify merb to support a fcgi
interface (actually a rack interface - rack is
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 this to the following it works fine:
2007 Jul 29
7
Merb test harness
Ezra,
* test harness in new generated merb apps with helpers for testing
merb without starting a server.
* pin down plugin arch
Seems to me that these two tasks go together unless you want to have
rspec built in Merb.
Regarding the test harness, my understanding is that:
- a developer should be able to easily write specs against a merb application.
- a developer should not need to start a merb
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?
2009 Aug 23
4
Routing problems for different formats
I am having 2 similar problems with routing.
1. With Rails if I make a js request using jQuery I always have to
append a ".js" extension to allow the request to be handled
appropriately. If I don''t append a js extension I get html formatted
data back. Using Merb this never happened and worked like I thought it
should.
2. Today I am having problems allowing xml requests to be
2009 Jun 14
3
Basic AJAX Response (Mootools)
Hi,
I''ve done AJAX calls to Rails'' Controllers before yet never required to
generate a response back to the view. In this respect, I have tried to
keep it moronically simple and just add a node to see that it works, yet
the response doesn''t come through / isn''t interpreted as it should. Long
story short, code :
// Have to use Mootools to integrate a
2006 Jul 31
2
is it possible to make to_xml use underscore instead of dash?
Hi all,
I am getting ActiveRecord to produce XML with
render :xml => @user.to_xml
However, on the client end it is a bit annoying for me to deal with
attributes like first-name. I would much rather have first_name.
Is there any way for me to turn off the behavior of converting _ to -?
This seems to be done by a call to dasherize inside the to_xml of
2007 Jan 20
0
Best way to force a respond_to format
I am playing around with the idea of adding to the HTTP_ACCEPT header
method and trying to utilize WURFL for detecting mobile devices by
USER_AGENT instead. I''m thinking I will set up some kind of
before_filter in my controller, to intercept all requests and compare
the USER_AGENT to some data source.
If I detect that the USER_AGENT is a mobile device, then I''d like to
force a
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"]
2007 Dec 02
3
Better way for select list for belongs_to?
I''m currently doing all of this just to have a drop-down list of
Courses for a particular student:
===== edit template =====
<%= f.select :course, @courses, :selected => @student.course.id %>
===================
===== students controller =====
def edit
@student = Student.find(params[:id])
@page_title = "Edit #{@student.full_name}"
@courses =
2009 Jan 09
2
Confused about to_xml() in ActiveRecord::Base subclass
Since all my efforts to control how to_xml() is formatting dates has
failed, I''m now considering writing my own to_xml(). However, from
the limited examples I''ve found, I just don''t understand how to
actually reference the columns for the records in my record set.
Here''s a simplified view of my ActiveRecord object:
class Errors < ActiveRecord::Base
2007 Nov 19
2
Help with controller and view
I have the following models
class Recipe < ActiveRecord::Base
has_many :ingredient_recipes
has_many :ingredients, :through => :ingredient_recipes
end
class IngredientRecipe < ActiveRecord::Base
belongs_to :ingredient
belongs_to :recipe
end
class Ingredient < ActiveRecord::Base
has_many :ingredient_recipes
has_many :recipes, :through => :ingredient_recipes
2007 Feb 21
1
Rendering all the elements when calling Array#to_xml
When I call to_xml on an array, I want it to get the XML for all the
elements in it. I''ve defined to_xml in my class.
>> r.to_xml
=> "<video><id>1</id><views>2</views></video>"
>> a = [r]
=> [#<StatisticsReport:0x3259f38 @video_id=1, @views=2>]
>> a.to_xml
=> "<?xml version=\"1.0\"
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
2007 Aug 28
1
what''s the view format in trunk?
dumb question but what''s the view format in trunk?
I have a simple router:
Merb::Router.prepare do |r|
# default route, usually you don''t want to change this
r.default_routes
# change this for your home page to be avaiable at /
r.add ''/'', :controller => ''upload'', :action =>''new''
end
I have a simple controller
2006 Aug 15
2
to_xml and underscores
hi,
i am looking for a solution whereupon
calling myEntityObject.to_xml does not
convert my attributes containing underscores
into hyphens.
at the moment an attribute named "my_own_attribute"
is converted into <my-own-attribute>.
does anybody have an idea how to change that
and have to_xml generate <my_own_attribute>
thanks
ciao robertj
--
Posted via
2007 Feb 15
3
Restrict attributes in to_xml
For example, let''s say I have a User model with 2 attributes:
1. pw_hash
2. pw_salt
I don''t want these to show up in the to_xml method. How do I keep to_xml
from using these attributes?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2009 Jan 05
5
ROXML versus simple to_xml
How they differ?
Does the to_xml method of the classes array/hash/object is based on
ROXML lib?
As I see in http://roxml.rubyforge.org/#quickstart, roxml needs we
define the class (class Book in the guide) before to convert a object
to xml. Moreover, the method to_xml (when not using "include ROXML")
just accepts any existing object, what is much suitable.
I need to compare and tranfer