简体   繁体   中英

Ruby on Rails forms: missing template on submit

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 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM