This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #232 from basvanwesting/fix_name_generation
fix "has_one => has_many => has_many" name generation
- Loading branch information
Showing
10 changed files
with
71 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* | ||
Place all the styles related to the matching controller here. | ||
They will automatically be included in application.css. | ||
*/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class CompaniesController < ApplicationController | ||
def new | ||
@company = Company.new | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Company < ActiveRecord::Base | ||
has_one :project | ||
accepts_nested_attributes_for :project | ||
|
||
after_initialize 'self.build_project' | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<%= nested_form_for @company do |f| -%> | ||
<%= f.text_field :name %> | ||
<%= f.fields_for :project do |pf| -%> | ||
<%= pf.text_field :name %> | ||
<%= pf.fields_for :tasks do |tf| -%> | ||
<%= tf.text_field :name %> | ||
<%= tf.fields_for :milestones do |mf| %> | ||
<%= mf.text_field :name %> | ||
<%= mf.link_to_remove 'Remove milestone' %> | ||
<% end %> | ||
<%= tf.link_to_add 'Add new milestone', :milestones %> | ||
<%= tf.link_to_remove 'Remove' %> | ||
<% end -%> | ||
<%= pf.link_to_add 'Add new task', :tasks %> | ||
<% end -%> | ||
<% end -%> |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class CreateCompany < ActiveRecord::Migration | ||
def self.up | ||
create_table :companies do |t| | ||
t.string :name | ||
end | ||
|
||
add_column :projects, :company_id, :integer | ||
end | ||
|
||
def self.down | ||
remove_column :projects, :company_id | ||
drop_table :companies | ||
end | ||
end |
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
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
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
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