<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>generators/getna/templates/controller.html.erb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -73,14 +73,14 @@ class GetnaGenerator &lt; Rails::Generator::NamedBase
         #app/controllers/ com o nome no Plural, passamos tambem as vari&#225;veis que devem ser mudadas
         #dentro dos Templates( Todos os NAMES acima.S ).
         #
-        m.template(&quot;controller.rb&quot;,&quot;app/controllers/#{name[:plural]}_controller.rb&quot;,:assigns=&gt;{:object_name=&gt;name})         
+        m.template(&quot;controller.html.erb&quot;,&quot;app/controllers/#{name[:plural]}_controller.rb&quot;,:assigns=&gt;{:object_name=&gt;name,:rel_props=&gt;@geobject.interrel[table_name]})         
 
         # == GENERATE Models
          # Para cada Tabela &#233; ent&#227;o copiado o template model.rb para  a pasta do projeto
         #app/models/ com o nome no Plural, passamos tambem as vari&#225;veis que devem ser mudadas
         #dentro dos Templates( Todos os NAMES acima.S ).
         #
-        m.template(&quot;model.html.erb&quot;,&quot;app/models/#{name[:single]}.rb&quot;,:assigns=&gt;{:object_name=&gt;name, :relationship=&gt;@geobject.relationship['usuarios']})#[&quot;PORRA&quot;,&quot;VSF&quot;,&quot;CARAI&quot;]})
+        m.template(&quot;model.html.erb&quot;,&quot;app/models/#{name[:single]}.rb&quot;,:assigns=&gt;{:object_name=&gt;name, :relationship=&gt;@geobject.relationship[table_name]})
      
         # == GENERATE Views Directory
         # Criamos o Diretorio que vai conter as Views com o nome da tabela no plural
@@ -91,10 +91,10 @@ class GetnaGenerator &lt; Rails::Generator::NamedBase
         #na Pasta que acabamos de gerar, utilizando seus respectivos templates view_edit.html.erb, view_index.html.erb,
         # view_show.html.erb, view_new.html.erb
         #
-        m.template(&quot;view_edit.html.erb&quot;,&quot;app/views/#{name[:plural]}/edit.html.erb&quot;,:assigns=&gt;{:attributes=&gt;attrs,:object_name=&gt;name})     
+        m.template(&quot;view_edit.html.erb&quot;,&quot;app/views/#{name[:plural]}/edit.html.erb&quot;,:assigns=&gt;{:attributes=&gt;attrs,:object_name=&gt;name,:if_relation_object=&gt;@geobject.interrel[table_name][0]})     
         m.template(&quot;view_index.html.erb&quot;,&quot;app/views/#{name[:plural]}/index.html.erb&quot;,:assigns=&gt;{:attributes=&gt;attrs,:object_name=&gt;name})    
         m.template(&quot;view_show.html.erb&quot;,&quot;app/views/#{name[:plural]}/show.html.erb&quot;,:assigns=&gt;{:attributes=&gt;attrs,:object_name=&gt;name})               
-        m.template(&quot;view_new.html.erb&quot;,&quot;app/views/#{name[:plural]}/new.html.erb&quot;,:assigns=&gt;{:attributes=&gt;attrs,:object_name=&gt;name})         
+        m.template(&quot;view_new.html.erb&quot;,&quot;app/views/#{name[:plural]}/new.html.erb&quot;,:assigns=&gt;{:attributes=&gt;attrs,:object_name=&gt;name,:if_relation_object=&gt;@geobject.interrel[table_name][0]})         
         
         # == GENERATE Routes
         # Geramos a rota para cada objeto gerado.</diff>
      <filename>generators/getna/getna_generator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,8 +5,10 @@
 &lt;%% form_for(@&lt;%= object_name[:single] %&gt;) do |f| %&gt;
 &lt;% for attribute in attributes -%&gt;
   &lt;p&gt;
-    &lt;b&gt;&lt;%= attribute[:name].humanize %&gt;&lt;/b&gt;&lt;br /&gt;
-    &lt;%%= f.&lt;%= attribute[:type] %&gt; :&lt;%= attribute[:name] %&gt; %&gt;
+    &lt;b&gt;&lt;%= attribute[:name].humanize %&gt;&lt;/b&gt;&lt;br /&gt;   
+    &lt;% if(collection = attribute[:name].match(/\A(.*)_id\z/) and if_relation_object )   %&gt;
+    &lt;%%= f.select :&lt;%=attribute[:name] %&gt;,@&lt;%= collection.captures.to_s.pluralize %&gt;,{:prompt=&gt;&quot;Selecione uma Op&#231;&#227;o&quot;} %&gt; &lt;% else %&gt;   
+    &lt;%%= f.&lt;%= attribute[:type] %&gt; :&lt;%= attribute[:name]%&gt; %&gt;&lt;% end %&gt;     
   &lt;/p&gt;
 
 &lt;% end -%&gt;</diff>
      <filename>generators/getna/templates/view_edit.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -5,8 +5,10 @@
 &lt;%% form_for(@&lt;%= object_name[:single] %&gt;) do |f| %&gt;
 &lt;% for attribute in attributes -%&gt;
   &lt;p&gt;
-    &lt;b&gt;&lt;%= attribute[:name].humanize %&gt;&lt;/b&gt;&lt;br /&gt;
-    &lt;%%= f.&lt;%= attribute[:type] %&gt; :&lt;%= attribute[:name]%&gt; %&gt;
+    &lt;b&gt;&lt;%= attribute[:name].humanize %&gt;&lt;/b&gt;&lt;br /&gt;   
+    &lt;% if(collection = attribute[:name].match(/\A(.*)_id\z/) and if_relation_object )   %&gt;
+    &lt;%%= f.select :&lt;%=attribute[:name] %&gt;,@&lt;%= collection.captures.to_s.pluralize %&gt;,{:prompt=&gt;&quot;Selecione uma Op&#231;&#227;o&quot;} %&gt; &lt;% else %&gt;   
+    &lt;%%= f.&lt;%= attribute[:type] %&gt; :&lt;%= attribute[:name]%&gt; %&gt;&lt;% end %&gt;     
   &lt;/p&gt;
 
 &lt;% end -%&gt;</diff>
      <filename>generators/getna/templates/view_new.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -8,8 +8,8 @@
 
 module Getna  
   class Base
-    attr_reader :connection,:table_names,:relationship
-    $VERSION = &quot;0.0.5&quot;
+    attr_reader :interrel, :table_names,:relationship
+    $VERSION = &quot;0.1.1&quot;
 
     def initialize (env)
       #Mensagen de inicializa&#231;&#227;o do sistema de gera&#231;&#227;o de codigo.
@@ -50,14 +50,17 @@ module Getna
         
         
        
+      @interrel = Hash.new 
       @relationship  = Hash.new
-      @table_names.each{|table|   @relationship.store(table,[]) }
+      
+      @table_names.each do |table|   
+        @relationship.store(table,[])
+        @interrel.store(table,[false])
+      end
       
       #Iniciando identifica&#231;&#227;o de relacionamentos
       has_many_through
-      $stdout.print(&quot;\n REL\n&quot;)
-      @relationship.each_pair {|key, value| $stdout.print(&quot;#{key} =&gt; #{value}\n&quot;) }
-      
+      @interrel.each_pair {|key, value| $stdout.print(&quot;#{key} =&gt; #{value}\n&quot;) }
     end
     
     
@@ -125,10 +128,9 @@ end
         if (decomp_tables = decompounds(table))
          # test(table)
           if  (tables_exist?(decomp_tables)) 
-            puts &quot;Tabela Exist&quot;
                 if (has_nxn_keys?(decomp_tables, table))
-                  puts &quot;YES KEYS&quot;
                       create_relation_nxn_for(decomp_tables,table)
+                      create_interface_nxn_for(decomp_tables,table)
                 end
           end 
           end   #END:: if Decomp_tables
@@ -152,30 +154,26 @@ end
     
     def has_nxn_keys?(rel_tables, thr_table)
      table_w_keys = []
+     rtables = rel_tables.dclone
       columns(thr_table).each do |attr|
-        puts &quot;Atributo: #{attr.name} &quot; +(attr.name.match(/\A(.*_id)\z/) ? &quot;&#233; Chave&quot; : &quot;N&#227;o &#233; chave&quot;)
+       # puts &quot;Atributo: #{attr.name} &quot; +(attr.name.match(/\A(.*_id)\z/) ? &quot;&#233; Chave&quot; : &quot;N&#227;o &#233; chave&quot;)
         
         if(attr.name.match(/\A(.*_id)\z/))
           table_w_keys.push(attr.name.chomp('_id').pluralize)
         end        
       end   
-    table_w_keys.each{|table| rel_tables.delete(table)}  
-   #puts &quot;TABLE_W_KEYS IS #{table_w_keys}&quot;    
-    puts &quot;REL_TABLES CONTENT #{rel_tables}&quot;
-    puts &quot;REL_TABLES IS EMPTY?#{rel_tables.empty?}&quot;
-    rel_tables.empty? 
+    table_w_keys.each{|table| rtables.delete(table)}  
+    rtables.empty? 
   end
   
     #Cria Relacionamento(REL_TABLE NAUM VEM)
     def create_relation_nxn_for(rel_tables,thr_table)
-      puts &quot;\n\n=======================\n\n&quot;
-      puts &quot;REL_TABLE: #{rel_tables}\n&quot;
+      #puts &quot;\n\n=======================\n\n&quot;
+     # puts &quot;REL_TABLE: #{rel_tables}\n&quot;
       my_tables = rel_tables
       rel_tables.each do |rtable|
         my_tables.each do |table|
-          puts &quot;RTable: #{rtable}\n\n&quot;
-          puts &quot;SHIP: #{@relationship[rtable]}\n\n&quot;
-             @relationship[rtable].push(&quot;has_many :#{table}, :through=&gt; :#{thr_table} &quot;) if table !=rtable
+             @relationship[rtable] &lt;&lt; &quot;has_many :#{table}, :through=&gt; :#{thr_table} &quot;&lt;&lt; &quot;has_many :#{thr_table} &quot; if table !=rtable
         end
        # puts &quot;THR: #{thr_table}&quot;
         @relationship[thr_table].push(&quot;belongs_to :#{rtable.singularize}&quot;)
@@ -186,6 +184,16 @@ end
     #==  Fim Da Sess&#227;o De Identifica&#231;&#227;o de Relacionamentos NxN  ====================#
     
     
+    def create_interface_nxn_for(rtables, thr_table)
+      $stdout.print(&quot;\n\nRELTABLES:  #{rtables}\n\n&quot;)
+      #@interrel[thr_table]=[true]
+      @interrel[thr_table]= rtables
+      @interrel
+    end
+    
+    
+    
+    
        #=================================================== 
 
  </diff>
      <filename>lib/getna.rb</filename>
    </modified>
    <modified>
      <diff>@@ -145,7 +145,6 @@ class CreateSampleDb &lt; ActiveRecord::Migration
       t.integer :numero, :null =&gt; false
       t.datetime :data_saida, :null =&gt; false
       t.datetime :data_retorno, :null =&gt; false
-      t.references :localidade, :null =&gt; false
       t.string :transporte
       t.string :previsao_km
       t.string :tecnico, :null =&gt; false</diff>
      <filename>samples/001_create_sample_db.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>generators/getna/templates/controller.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>5825301bc37284721dfec0a3b8029038ffe7a059</id>
    </parent>
  </parents>
  <author>
    <name>LuizCarvalho</name>
    <email>maximusmano@gmail.com</email>
  </author>
  <url>http://github.com/LuizCarvalho/getna/commit/bd1970f1429c5935eb6a27ed31f872c7ef343061</url>
  <id>bd1970f1429c5935eb6a27ed31f872c7ef343061</id>
  <committed-date>2008-10-29T13:42:04-07:00</committed-date>
  <authored-date>2008-10-29T13:42:04-07:00</authored-date>
  <message>Concluido Relacionamentos NxN (Betha). New Version: 0.1.1</message>
  <tree>45fbaa7011576868c7970a1eca809133f82c5858</tree>
  <committer>
    <name>LuizCarvalho</name>
    <email>maximusmano@gmail.com</email>
  </committer>
</commit>
