Created
September 2, 2013 11:52
-
-
Save kmelkon/6412078 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<fieldset> | |
<div class="control-group"> | |
<%= f.label :place, :class => "remember control-label" %> | |
<div class="controls"> | |
<%= f.select :place, ['Work', 'Mobile', 'Other'], {}, { :class => "input-xlarge" } %> | |
</div> | |
</div> | |
<div class="control-group"> | |
<%= f.label :number, :class => "control-label" %> | |
<div class="controls"> | |
<%= f.text_field :number, size: '20', :class => "input-width field-clear" %> | |
</div> | |
</div> | |
<div class="control-group"> | |
<%= f.label :email, :class => "control-label" %> | |
<div class="controls"> | |
<%= f.text_field :email, size: '20', :class => "input-width field-clear" %> | |
</div> | |
</div> | |
<a href="#" class="remove" data-confirm="Are you sure?">remove</a> | |
<%= f.hidden_field :id %> | |
<%= f.hidden_field :_destroy %> | |
</fieldset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Contact < ActiveRecord::Base | |
attr_accessible :background, :bcard, :company_id, :first_name, :last_name, :linked_in, :user_id, :phone_numbers_attributes | |
belongs_to :company | |
belongs_to :user | |
has_many :tasks | |
accepts_nested_attributes_for :company | |
has_many :phone_numbers | |
accepts_nested_attributes_for :phone_numbers, allow_destroy: true | |
mount_uploader :bcard, FileUploader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="items"> | |
<a href="#" class="add">add phone</a> | |
<%= f.nested_fields_for :phone_numbers do |f| | |
render 'companies/phone', f: f | |
end %> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Started POST "/contacts" for 127.0.0.1 at 2013-09-02 14:50:04 +0300 | |
Processing by ContactsController#create as JS | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Nhflt/o9HdfsWXpsSaKddd5yvItOsGtDoFD5N/Rbfns=", "contact"=>{"first_name"=>"esdzxc", "last_name"=>"", "company_id"=>"1", "phone_numbers_attributes"=>{"1378122596463"=>{"place"=>"Work", "number"=>"1234", "email"=>"awds", "id"=>"", "_destroy"=>"false"}}, "linked_in"=>"", "background"=>""}, "commit"=>"Add Contact"} | |
Company Load (0.2ms) SELECT "companies".* FROM "companies" WHERE "companies"."id" = 1 LIMIT 1 | |
(0.1ms) begin transaction | |
SQL (348.7ms) INSERT INTO "contacts" ("background", "bcard", "company_id", "created_at", "email", "first_name", "last_name", "linked_in", "updated_at", "user_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["background", ""], ["bcard", nil], ["company_id", 1], ["created_at", Mon, 02 Sep 2013 11:50:04 UTC +00:00], ["email", nil], ["first_name", "esdzxc"], ["last_name", ""], ["linked_in", ""], ["updated_at", Mon, 02 Sep 2013 11:50:04 UTC +00:00], ["user_id", nil]] | |
SQL (0.3ms) INSERT INTO "phone_numbers" ("company_id", "contact_id", "created_at", "email", "number", "place", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["company_id", nil], ["contact_id", 8], ["created_at", Mon, 02 Sep 2013 11:50:04 UTC +00:00], ["email", "awds"], ["number", "1234"], ["place", "Work"], ["updated_at", Mon, 02 Sep 2013 11:50:04 UTC +00:00]] | |
(166.7ms) commit transaction | |
Rendered contacts/_contact_card.html.erb (0.8ms) | |
Rendered contacts/_contact_info.html.erb (1.0ms) | |
Rendered contacts/create.js.erb (3.8ms) | |
Completed 200 OK in 601ms (Views: 38.4ms | ActiveRecord: 516.0ms) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PhoneNumber < ActiveRecord::Base | |
attr_accessible :company_id, :contact_id, :place, :number, :email | |
belongs_to :company | |
belongs_to :contact | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment