Hello all,
Has anyone done one of these? I’ve done similar things in java and php,
by having easy access to SQL statements. I am new to Ruby/Rails( I’ve
been at it for 10 days ) and thus far find it extremely confusing. I’ve
got a bit more of a handle on it from the Agile book that someone loaned
me, but I still find it hard to understand.
Anyway, I’ve got two tables with a one to many between them. I am able
to have a page display the parent table and its asscociated fields for
CRUD, but I am baffled at how to get at the child table for updating and
creating. Here is where I am at:
When you go to the edit page for the parent table, I’ve placed a link
that brings you to a new page with this:
Editing Module Unit ID: <%= @moduleunit.id %> Links
<%= start_form_tag :action => ‘updatelinks’, :id => @moduleunit %>
<%= render :partial => ‘linkform’ %>
<%= submit_tag ‘Edit Links Entry’ %>
<%= end_form_tag %>
<%= link_to ‘Show’, :action => ‘show’, :id => @moduleunit %> |
<%= link_to ‘Back’, :action => ‘list’ %>
where moduleunit is the primamry key of the parent table. This loads the
linkform partial( is that correct? ) which contains this:
<% for modulelink in @moduleunit.modulelinks %>
I’ve appended the child primamry key because there may be more than one
and I saw no facility in rails to handle this.
At this point, I am trying to make a method in the parent controller
called updatelinks but cannot get things working with .find or
params[:id] or anything else.
Is there a way I can just use plain SQL here? I know it is not the rails
way, but I just need to get this working and I have spent too long
trying it through rails syntax, getting more confused, etc. There must
be an easier way through straight SQL, yes?
Thanks and sorry for being so clueless. I just can’t “get” rails