I
Israel Guerra
[Note: parts of this message were removed to make it a legal post.]
Hi ppl.
I am noob in rails and started an app to learn. I have the following
scenario:
table client with fileds: name, second_name
table phone with fields: number, client_id
table address with fields: street, number, client_id
The migrations worked ok and the fields are created.
Now i defined in the model that
for client:
has_many
hones
has_many :adresses
for phones and adresses:
belongs_to :client
I made a form to get some of these fields and add to the database:
<% form_for
clients) do |f| %>
<p>
<b>Name</b>
<%= f.text_field :name %>
</p>
<p>
<b>Second Name</b>
<%= f.text_field :second_name%>
</p>
<p>
<b>Number</b>
<%= f.text_field :number%>
</p>
<p>
<%= f.submit "Add" %>
</p>
<% end %>
And in the controller i try to save it to the DB:
@clients = Clients.new(params[:clients])
@clients.save
When i submit i get an error saying that number is not a method, it means it
didnt associate number with a cliente. It's not "joining" the tables.
Where did i made a mistake here?
Thanks guys.
Hi ppl.
I am noob in rails and started an app to learn. I have the following
scenario:
table client with fileds: name, second_name
table phone with fields: number, client_id
table address with fields: street, number, client_id
The migrations worked ok and the fields are created.
Now i defined in the model that
for client:
has_many
has_many :adresses
for phones and adresses:
belongs_to :client
I made a form to get some of these fields and add to the database:
<% form_for
<p>
<b>Name</b>
<%= f.text_field :name %>
</p>
<p>
<b>Second Name</b>
<%= f.text_field :second_name%>
</p>
<p>
<b>Number</b>
<%= f.text_field :number%>
</p>
<p>
<%= f.submit "Add" %>
</p>
<% end %>
And in the controller i try to save it to the DB:
@clients = Clients.new(params[:clients])
@clients.save
When i submit i get an error saying that number is not a method, it means it
didnt associate number with a cliente. It's not "joining" the tables.
Where did i made a mistake here?
Thanks guys.