views:

266

answers:

1

My controller has two methods: index and search.

def index: renders the default view, index.html.erb, and displays a default map using YM4R/GM.

def search: renders the default view using render index, but uses form input to display a custom map using YM4R/GM.

The view, index.html.erb, contains a partial view, _form.html.erb, and the @map.div for YM4R/GM.

The map displays fine when rendered through the default, but when submitted to the search method I get the error:
Template is missing. Missing template ym4r/gm_plugin/variables/_variable.erb in view path app/views.

What's weird is that I had this working yesterday until I started jacking around with trying to make my form submit using form_remote_tag. I started getting this error with that type of call so now I've changed everything back (I think), but I'm still getting the error. I think there's something I don't understand about how Rails renders views.

A: 

As you've pointed out here, there's an important difference between a method and a string.

# Call the index method, then render the result, whatever that is. Does not work as
# expected.
render(:action => index)

# Render using the index template
render(:action => 'index')

Ruby is really relaxed when it comes to calling methods so there's no requirement to use brackets as is the case with others such as JavaScript or Perl.

tadman
Nice explanation for the sake of posterity.
Donald Hughes