Forum: Ruby on Rails empty text_area yields 'Template is missing' error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
94d4d7d1b78391266fea8e739c9405c5?d=identicon&s=25 Dan Kelley (dankelley)
on 2007-03-09 01:03
PROBLEM STATEMENT

My app gives a missing-template error if the user enters nothing into a
provided text_area.  But if something is provided, everything works
fine.

I'm still a newbie, so I don't really understand the automatic
connection between things.  Is it a problem that I have
"views/thingee/new.rhtml"  and a "create" method in
"controllers/thingee_controller.rb", where . stands for my thingee.  I'm
guessing not, since it's OK if I give content to the text_area.  But
maybe I'm still supposed to follow a convention, and the problem only
crops up with empty content ...???

You can tell by the fact that I write "thingee" that I don't really know
what words to use for things, and I've not discovered a standard
convention by scanning these forum postings.


APPLICATION SETUP


1. In views/thingees/new.rhtml

<% form_for :foo, :url => {:action => 'create'} do |form| %>
  <%= form.text_area :content, :cols => 60, :rows => 4 %>
  <%= text_field_with_auto_complete :tag, :content, { :size => 60},
{:skip_style => false, :tokens => [' ', ',', ';']} %>
  <%= submit_tag "Submit" %>
<% end %>

2. In app/controllers/thingees_controller

  def create
    ...
    if @rabbit.save
      (NEVER GETS HERE)
    ...

3. In app/db/migrate/001_create_thingees.rb

   ...
   t.column :content, :text, :default => ""
   # NB. I've also tried no default, and a nil default.
This topic is locked and can not be replied to.