Christaan Van den Poel
unread,Jun 24, 2010, 4:19:51 AM6/24/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby on Rails: Core
I've the following situation (which actually works in Rails 2.3.8 and
this is a result of the migration of our app to rails3):
I have a partial which is rendered a few times (imagine tr's in a
table). On the clientside there's a script that does a json request
for a specific row (jQuery + ajax dataType: 'json' and type: 'POST')
In the controller I do:
render :json => { :success => true, :p => render_to_string(:partial =>
'some_partial') }
Then the ajax result handler replaces the row with the data from the
json result.
This is 100% functional code in rails 2.3.8, but raises
MissingTemplate exception:
ActionView::MissingTemplate (Missing partial employees/
employee_list_row_data with
{:handlers=>[:haml, :builder, :erb, :rjs, :rhtml, :rxml], :formats=>[:json, :js, :"*/
*"], :locale=>[:en, :en]} in view paths ...
So it seems that the requested formats are used to search for the
templates.
First question: is this change deliberate? Is it now necessary to
have templates in the form of: "xxx.erb" (without the 'html') so it
can be used for requests in other formats? Removing the '.html' part
of the file fixes this problem. I just want to know whether this is as
expected or a bug.
Second question: when I look at the query (actionpack/lib/action_view/
template/resolver.rb line 71) it is like this: app/views/layouts/
tags{.en,.en,}{.json,.js,.*/*,}
{.haml,.builder,.erb,.rjs,.rhtml,.rxml,} You can see it uses the
request.format '*/*' also in the Dir[query]. Is this possibly a bug?
Because in (/home/cvp/myprojects/github/rails@github/actionpack/lib/
action_view/template/resolver.rb line 152 there's the following code
# Overload formats= to reject [:"*/*"] values.
def formats=(values)
if values && values.size == 1
value = values.first
values = nil if value == :"*/*"
values << :html if value == :js
end
super(values)
end
I see there's specific code to handle '*/*' formats but only when this
is the only requested format. Is this possibly a bug?
TIA
C+++