Default Render Action or Help Cleaning Up My View Folder

I have 30 actions which all render basically the same thing, basically
their name and a message either indicating success or failure:

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
    <title><%= "#{action_name} Update Result" %></title>
  </head>
  <body>
    <%= message %>
  </body>
</html>

The trouble is, in order to do this I have a layout (partly shown
above) and then 30 blank files in my view directory named after the
actions they are associated with. I see no reason I have to create 30
blank view files. However, if I don't create the file then Rails will
not render the view because it will error out on not being able to
find an associated view file for this action.

I have considered adding a render line to the bottom of every action,
something like render :file => "layouts/mylayout" but it seems that's
more or less a brute force resolution like making 30 files is a brute
force solution.

Can I specify a default file to render for every action in a
controller? Someone has to know a more elegant, railsy solution to
this problem!

Thanks for your help,

Chris

You could use “after_filter :default_render” and then

private

def default_render

render => …

end

But probably there is a better sollution here: http://api.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html

The after_filter thing I tried before, and it causes a double-render
condition. I would then need to go through all the functions and do
render :none or something to that effect... Which just goes back to
the render at the end of each function problem.

Chris

Maybe you could try “before_filter” :slight_smile:

But nothing on http://api.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html solved your problem? :S