All,
I have ordered AWDWR and am anxiously awaiting its arrival. In the
meantime I still am playing with ROR using radrails. I have a few
questions …
I create a table named customers with the following details:
Field Type Null Key Default Extra
id int(11) NO PRI auto_increment
customer_name varchar(50) NO
inbound_retention int(11) NO
outbound_retention int(11) NO
unix_admin_email varchar(50) NO
schedule_id int(11) NO
transfer_inbound_type varchar(20) NO
transfer_outbound_type varchar(20) NO
date_added timestamp YES CURRENT_TIMESTAMP
I then run the scaffold generation:
ediweb> ruby script/generate scaffold customer Customerinfo
exists app/controllers/
exists app/helpers/
exists app/views/customerinfo
exists test/functional/
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/customer.rb
create test/unit/customer_test.rb
create test/fixtures/customers.yml
identical app/views/customerinfo/_form.rhtml
create app/views/customerinfo/list.rhtml
create app/views/customerinfo/show.rhtml
create app/views/customerinfo/new.rhtml
create app/views/customerinfo/edit.rhtml
create app/controllers/customerinfo_controller.rb
create test/functional/customerinfo_controller_test.rb
create app/helpers/customerinfo_helper.rb
create app/views/layouts/customerinfo.rhtml
create public/stylesheets/scaffold.css
I understand this creates my model, controller, and view. My question
is if I want to only allow a user to see certain information in the list
and only be able to add new information to certain fields where do I
begin? I look at my list.rhtml for customerinfo and see the following
(after some other html):
<% for column in Customer.content_columns %>
<% end %>
I realize this is what prints out each line, but how do I begin
specifying only certain columns to be printed? I guess I don’t
understand the customer.send(column.name). If someone has a good
tutorial on customizing views when using scaffolds to build the initial
files please link me.
Also, under new.rhtml I see:
New customer
<%= start_form_tag :action => ‘create’ %>
<%= render :partial => ‘form’ %>
<%= submit_tag “Create” %>
<%= end_form_tag %>
<%= link_to ‘Back’, :action => ‘list’ %>
What would I edit here to only allow certain fields in the table to be
inserted? Once again, a tutorial of ROR view customization would be
greatly appreciated. I’m very new to ROR and that book is going to take
a few days to get here!
-James