similar to: The latest & greatest Routing (Rails Edge 4611)

Displaying 20 results from an estimated 5000 matches similar to: "The latest & greatest Routing (Rails Edge 4611)"

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
2008 Aug 28
12
Rendering User attributes in XML
Let''s say an app has a User, and a User has many friends. Also, let''s say the app authentication was built on the restful_authentication plugin, and we have email and password in the Users table. The friends controller index might look like this; # GET /users/1/friends # GET /users/1/friends.xml def index @users = @user.friends respond_to do |format| format.html
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
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 =
2006 Mar 17
3
Best debugger for Rails on Linux
A quick survey... what''s the best gui debugging tool for Rails 1.0 on Linux that you''ve used? SW versions? Personally I''ve tried FreeRIDE 0.95 and RDT 0.7.0 in Eclipse 3.1.2. Both are very slow and the latter got quite a few bugs itself. TIA! -- Posted via http://www.ruby-forum.com/.
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
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:
2006 Jul 31
3
Simply_RESTful and Bulk Import URLs
Hi, I have a people controller, and want to import bulk import multiple people from a CSV file. In my routes.rb file I have: map.resource :person Now, it''s a little unclear to me how to further configure the routes to allow me to add the following URLs: I need a URL to choose a file to upload, so I need an HTML ''frontend'' for it, so I figured the following URL
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 Nov 26
1
transition form respond_to to provides
I really like the new mime type handler however I was trying to convert some code and couldn''t figure out how. My rails action was handle 2 formats, html and xml respond_to do |format| format.html # show.html.erb format.xml do if @account.active? && @account.valid_referer?(session[:referer]) render :xml => @account.to_xml(:except
2008 Sep 19
7
Non-Ruby REST client for Ruby REST server
Hi, I have a Rails 2 app and I wand to provide an API for 3rd party applications written on any language the customer uses. My thoughts are that the best way of providing it is by taking advantage of rails RESTfulness and let them perform CRUD actions on my data through it. But I don''t seem to find many information on how to achieve this. I first want to develop .NET clients (or web
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 Jul 12
3
Agh, this is annoying. Why is this happening?
My problem: Mock ''Task_1005'' received unexpected message :user_id= with (1) No matter what I do to try to stub that out it will still fail out and give me that message. Here is my spec describe TasksController, "handling POST /tasks" do before(:each) do @task = mock_model(Task, :to_param => "1", :save => true)
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 Jul 26
4
How to Firebug XHR/AJAX requests
Saw a lot of recommendations for Firebug (http://www.joehewitt.com/software/firebug/) on this list. I''ve scanned its docs and tried it--many useful features. But I''m so dense that I can''t get it to spy XHR/AJAX requests and their response on FC5 running Firefox 1.5.0.4 and Firebug 0.4. Can someone tell me how to get to
2008 Jun 28
19
Stopping example execution?
Hello, I''m wondering If I am missing something here when creating an example that sets an expecation at the top or beginning of an action but requires you to stub / mock everything that follows. Example: I want to test that a certain controller is running a before_filter...thats easy: - controller.should_receive(:require_user) - do_get But now i''ve got to mock / stub
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"]
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
2006 Apr 14
2
Language setting before routing?
When processing a request, where can you obtain the language setting of a user''s browser? I know we can read @request.env["HTTP_ACCEPT_LANGUAGE"] in an action easily. But I need to access it before being routed to a controller''s action... because the accepted language dictates my app''s language setting programmatically and what action to take.
2007 Aug 22
1
ActiveResource find method and restful controllers.
Hi, What''s the best way to add support for the activeresource find method in the controllers in my rails app? As I understand it when you invoke something like: Person.find(:all, :params => {:name = ''toby''}) this generates a request of: GET /people.xml?name=toby Does this mean that in my index method in PeopleController in my rails app I have params[name] set to