Displaying 20 results from an estimated 90000 matches similar to: "formats available for controller"
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 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
2009 Jan 21
3
Nested serialization with to_json and to_xml with array and hash element
Title: Nested serialization with to_json and to_xml with array and
hash element
class Person < ActiveRecord::Base
has_one :address
has_one :job
def office()
return "Executive_Suite"
end
end
class Address < ActiveRecord::Base
belongs_to :person
end
class Job < ActiveRecord::Base
belongs_to :person
has_one :paygrade
def Title
return "Engineer"
end
end
2008 Jan 18
3
Please help
Hello all,
I have developed a RESTFul webservice in RoR. Here under is the controller
---------------------------------------------------------------------------------------------------------
class PeopleController < ApplicationController
def index
list
render :action => ''list''
end
# GETs should be safe (see
http://www.w3.org/2001/tag/doc/whenToUseGet.html)
2007 Apr 04
0
error occurred while evaluating nil.accepts
I have an index method with a respond_to block that produces this
error:
NoMethodError (You have a nil object when you didn''t expect it!
The error occurred while evaluating nil.accepts):
The show method has the same respond_to block but doesn''t error out.
If I take the respond_to block out of the index method, it works.
If I give index params[:keywords] I get this error:
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 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
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 =
2008 Jan 08
1
howto rebuild a object from a received xml hash structure ?
im my web server app , i have an action to be used as a REST web
service
# GET /user/membership.xml?email=emailaddress
def membership
@user = User.find_by_email(params[:email])
respond_to do |format|
format.xml { render :xml => @user.to_xml( :only =>
[ :first_name, :last_name, :display_name, :membership_type, :membership_at], :skip_types
=> true)}
end
end
my
2006 Jun 28
0
ActiveResource (was: 1.1.3 available.)
2006/6/28, Paul Barry <mail@paulbarry.com>:
> Where can I find info about the "CRUD/resource-based features" that will be
> in 1.2.0?
In blogs. Especially about Railsconf and DHH''s keynotes.
In trunk : http://dev.rubyonrails.org/browser/trunk/activeresource
In DHH slides :
Transcription of some slides from DHH''s talk at RubyKaigi 2006
(I suppose it must
2007 Oct 29
0
would this be a good(restfull) approach for livesearch?
Hi,
I want to implement a search feature with the rest principles in mind.
so i try to think in resources and i decided to just put in in the index
method.
this resource/method will be called form different places, for example a
main search page for organisations but also on a "person" form in a
sort of dialog screen where i can link an organisation to a person. the
(live) search
2009 Mar 08
0
undefined variable or method in form_tag url
Hello list,
In ref. to my previous post: http://www.ruby-forum.com/topic/180765
I am getting "undefined local variable or method `item_path'' for
#<ActionView::Base:0xb7065650>", when I try to create a new item.
Following is the code in my new.rhtml
<h1>New <%= @is_subitem ? ''Subitem'' : ''Item'' %></h1>
<% form_tag
2007 Apr 24
1
problem POSTing with curl and REST using scaffold_resource
I issued the following curl command to post to the database using
REST:
curl -i -X POST -d "<heartrate><heartRate>102</
heartRate><sessionID>1002</sessionID><timeStamp>15068</timeStamp></
heartrate>" http://localhost:3000/heartrates
I have tested the GET (with curl also) and it works fine!
curl http://localhost:3000/heartrates/45
2006 Dec 26
0
acts_as_taggable Plugin issue (not gem)
I tried to post this earlier, but it never came through. I''ve got
something working in console, but not in controller. Any idea why?
This is the plugin not the gem of acts_as_taggable
*View*
<code>
<h1>Listing elements</h1>
<% if @elements.blank? %>
<p>There are currently no elements in the system tagged <%=
2012 May 28
1
rendering a partial inside another using render_to_string and (:formats) in controller
I want to clean my code by moving the duplicated lines :
partial = render_to_string( :partial => "#{file}", :formats =>
[:html] )
to the pagination_partials function.
=================================================
WORKING CODE:
=================================================
def render_format_search_partial(file, options={})
# TODO remove this line to use the one
2009 Apr 12
1
handling ActiveRecord::RecordNotFound
How should we handle requests for invalid objects which do not exist in
database, ActiveRecord::RecordNotFound error ?
I am writing begin-rescue as follows:
def show
begin
@phone = Phone.find(params[:id])
rescue ActiveRecord::RecordNotFound
flash[:notice] = NONEXIST_OBJECT
redirect_to :controller => :phone, :action => :index
else
respond_to do |format|
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
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 Sep 11
5
WebServices & controllers
Hi,
I am having problems with REST web-service support.
I have a simple controller:
class DocumentsController < ApplicationController
wsdl_service_name ''Documents''
web_service_api DocumentsApi
web_service_scaffold :invoke
def list
@docs = Document.find(:all)
respond_to do |wants|
wants.html
wants.xml { return @docs .to_xml }
end
end
end
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