This project is archived and is in readonly mode.
render does not take symbol as template argument
-
Santiago Pastorino
- State changed from new to invalid
- Importance changed from to Low
template option expect controller/action.
I think you want to do render :action => :index or just render :index. -
James B. Byrne
I think that that appraisal rather misses the point. The issue is one of 'least surprise'. Is there a strong technical reason why symbols should not be allowed as targets to the :template key in the render hash? If not, then why are not symbols permitted to substitute for strings as they generally are elsewhere? Why the exception in this particular case?
-
José Valim
If render :template => "index" works, that is the bug. We don't expect it to. render :template accepts a path to the view, like "posts/index". render :template => "index" should just work if you have a file at app/views/index.html.erb.
-
Santiago Pastorino
Because template option expects a '/'
-
James B. Byrne
Then is there a case for the render method to return a specific ArgumentError message in the event it receives a symbol rather than a string as the value for the :template key? I follow that the present error implies that a Sting is expected but given the frequent interchangeability of strings with symbols within Rails perhaps an ArguemntError containing the explicit statement that the :template parameter requires a String argument would be useful.
-
Neeraj Singh
- Assigned user set to José Valim
render template => 'index' works because the following method converts options from
{:template => 'index'}to
{:template=>"index", :tempalte=>"index", :prefix=>"users"}#abstract_controller/rendering.rb def _normalize_options(options) if options[:partial] == true options[:partial] = action_name end if (options.keys & [:partial, :file, :template, :once]).empty? options[:prefix] ||= _prefix end options[:template] ||= (options[:action] || action_name).to_s options end -
Neeraj Singh
Never mind. I had a typo.
as @JV said it expects /index.