Unable to get input for certain fields to post to mySQL db


#1

I am just a little bit beyond customizing my scaffolding. Another way of
saying I am a Rails Rookie : )

Here is my problem:

About 50% of the code in my view below is working.

Example:

First Name

However. anything that is contained within <%= /> will not write to the
db.

Example 1:

Hope for the Homeless Youth:
<% @choices.each do |choice| %> <%= choice.name %> <% end %>

Example 2:

1A Start Date
<%= date_select ("post","written_on",:start_year => 1980,:use_month_numbers => false,:include_blank => true,:order => [:month,:day,:year])%>

What do I need to do in the controller, model, view, helper, etc to get
it to write these values to the db? My date fields are defined as date
and my question fields as text in mySQL. Below is my new.rhtml code
which is working for 50% of the fields, but again anything with a <%=
xxxxxxx /> will not insert into mySQL db.

Thanks again for your help!

new.rhtml code below.

New Contact

New Contact

First Name

Last Name

Address1

Address2

City

State

Zip

Country

Home Phone

Cell Phone

Work Phone

Other Phone

Work Email

Personal Email

Website

Occupation

Church Affiliation

Hope for the Homeless Youth:
<% @choices.each do |choice| %> <%= choice.name %> <% end %>

Personal Ministry Start Date
<%= date_select ("post","written_on",:start_year => 1980,:use_month_numbers => false,:include_blank => true,:order => [:month,:day,:year])%> Personal Ministry End Date
<%= date_select ("post","written_on",:start_year => 1980,:use_month_numbers => false,:include_blank => true,:order => [:month,:day,:year])%>

1A Start Date
<%= date_select ("post","written_on",:start_year => 1980,:use_month_numbers => false,:include_blank => true,:order => [:month,:day,:year])%>

1A Certificate Date
<%= date_select ("post","written_on",:start_year => 1980,:use_month_numbers => false,:include_blank => true,:order => [:month,:day,:year])%>

1B Start Date
<%= date_select ("post","written_on",:start_year => 1980,:use_month_numbers => false,:include_blank => true,:order => [:month,:day,:year])%>

1B Certificate Date
<%= date_select ("post","written_on",:start_year => 1980,:use_month_numbers => false,:include_blank => true,:order => [:month,:day,:year])%>

2A Start Date
<%= date_select ("post","written_on",:start_year => 1980,:use_month_numbers => false,:include_blank => true,:order => [:month,:day,:year])%>

2A Certificate Date
<%= date_select ("post","written_on",:start_year => 1980,:use_month_numbers => false,:include_blank => true,:order => [:month,:day,:year])%>

2B Start Date
<%= date_select ("post","written_on",:start_year => 1980,:use_month_numbers => false,:include_blank => true,:order => [:month,:day,:year])%>

2B Certificate Date
<%= date_select ("post","written_on",:start_year => 1980,:use_month_numbers => false,:include_blank => true,:order => [:month,:day,:year])%>

3A Start Date
<%= date_select ("post","written_on",:start_year => 1980,:use_month_numbers => false,:include_blank => true,:order => [:month,:day,:year])%>

3A Certificate Date
<%= date_select ("post","written_on",:start_year => 1980,:use_month_numbers => false,:include_blank => true,:order => [:month,:day,:year])%>

RLM Teacher:
<% @choices.each do |choice| %> <%= choice.name %> <% end %>

RLM Assistant:
<% @choices.each do |choice| %> <%= choice.name %> <% end %>

RLM Board Member:
<% @ choices.each do |choice| %> <%= choice.name %> <% end %>

RLM Donor:
<% @choices.each do |choice| %> <%= choice.name %> <% end %>

RLM Volunteer:
<% @choices.each do |choice| %> <%= choice.name %> <% end %>

RLM Gifting

Notes

Back

below is my controllers

class RlmController < ApplicationController
scaffold :rlm

  def new
            @rlms = Rlm.new
           @choices = Choice.find_all
  end

 def edit
         @rlm = Rlm.find(@params["id"])
        @choices = Choice.find_all
 end

end

class ChoiceController < ApplicationController
scaffold :choice
end

below are my models

class Rlm < ActiveRecord::Base
belongs_to :choice
end

class Choice < ActiveRecord::Base
has_many :rlms
end


#2

Hi Rod,

The first thing I’d recommend is that you switch to using explicit
scaffolding. It’ll give you a better default view of how Rails works.
The
use of the implicit scaffolding technique has pretty much come to be
seen as
something that’s better left until someone’s reached a fairly advanced
knowledge of Rails and what it does by default.

To address your question more directly, I’m not sure the mix of Rails
and
HTML you’ve got in your view below is going to work. I could be wrong,
but
with the form tags being in html but the fields you want to return to
the
server being in embedded Ruby, I’d be surprised if Rails is generating
the
form html you need. Take a look at your page source and have a look.

WRT advancing your understanding of Rails, O’Reilly just published the
second part of the updated “Rolling with Ruby on Rails” tutorial. It
uses
the explicit scaffolding.

http://www.onlamp.com/pub/a/onlamp/2006/12/14/revisiting-ruby-on-rails-revisited.html?page=1

Depending on what else you’ve already done, that might be a good place
to
start (please forgive the shameless self-delivered-plug).

hth,
Bill