Forms help

Ok, so in the middle of learning Ruby, things jumped to 2.0.2 and now
i’m having to relearn. I can’t find any answers on this.

in new.rhtml.erb I have the following code:

<%= error_messages_for :failure %>

<% form_for(@failure) do |f| %>
<%= render :partial => “form”, :locals => { :f => f, :button =>
“Create” } %>
<% end %>

I created a new file named: _form.rhtml.rb and and have the following:

Bus unit
<%= f.text_field :bus_unit %>

Pro num
<%= f.text_field :pro_num %>

Ship num
<%= f.text_field :ship_num %>

Rbna num
<%= f.text_field :rbna_num %>

Basically I moved what was automatically generated by the scaffolding
to the new file _form.rhtml.erb. I did this because I plan on
changing the “Bus Unit” to a drop down box with 3 options. Everything
I’ve found suggest that this is how I need to do it. However, I get
the following error:

Couldn’t find template file for failures/_form in [“C:/apps/yrcsphere/
app/views”]

(If you want, you can find more at http://athel.homeftp.net/failures/new
).

What am I doing wrong? Where can I find any documentation on
scaffolding/rails and making forms?

Thanks

~Athel

On 2/10/08, Athel [email protected] wrote:

“Create” } %>
<% end %>

I created a new file named: _form.rhtml.rb and and have the following:

Is that a typo? It should be _form.html.erb

Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

Yes, its a typo, sorry, I have it named _form.rhtml.erb

On 2/10/08, Athel [email protected] wrote:

Yes, its a typo, sorry, I have it named _form.rhtml.erb

Okay, so directory is it in, and what’s the controller?


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

its in the directory of:

C:\apps\yrcsphere\app\views\failures

and the controller is

C:\apps\yrcsphere\app\controllers\failures_controller.rb

On 11 Feb 2008, at 02:22, Athel wrote:

Yes, its a typo, sorry, I have it named _form.rhtml.erb

That’s still wrong. _form.html.erb is what it should be

Fred

On 2/10/08, Athel [email protected] wrote:

its in the directory of:

C:\apps\yrcsphere\app\views\failures

and the controller is

C:\apps\yrcsphere\app\controllers\failures_controller.rb

Hmm, that all sounds right to me. I’d suggest checking permissions on
the file, but since I see you’re on Windows, I’m not sure that makes
sense either.


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

I am so sorry. That fixed it. When you said typo, I checked my
original post and was missing the e in *erb. Renaming it to
_form.html.erb completely fixed it.

Thank you all.

On 2/11/08, Frederick C. [email protected] wrote:

Yes, its a typo, sorry, I have it named _form.rhtml.erb

That’s still wrong. _form.html.erb is what it should be

Good catch Fred, I’d assumed he was saying that it was named as I’d
suggested.


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/