forked from alloy/complex-form-examples
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Tag as a quick test of has_and_belongs_to_many with nested_params.
- Loading branch information
Showing
12 changed files
with
108 additions
and
2 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Tag < ActiveRecord::Base | ||
validates_presence_of :name, :message => "can't just be blank" | ||
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,9 @@ | ||
<div class="tag"> | ||
<% pf.fields_for :tags, tag do |f| %> | ||
<p> | ||
<%= f.label :name, "Tag:" %> | ||
<%= f.text_field :name %> | ||
<%= link_to_function "remove", "$(this).up('.tag').remove()" %> | ||
</p> | ||
<% 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
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,12 @@ | ||
class CreateTags < ActiveRecord::Migration | ||
def self.up | ||
create_table :tags do |t| | ||
t.string :name | ||
t.timestamps | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :tags | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
db/migrate/20081009223404_create_projects_tags_join_table.rb
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 CreateProjectsTagsJoinTable < ActiveRecord::Migration | ||
def self.up | ||
create_table :projects_tags, :id => false do |t| | ||
t.integer :project_id | ||
t.integer :tag_id | ||
end | ||
add_index :projects_tags, :project_id | ||
add_index :projects_tags, :tag_id | ||
end | ||
|
||
def self.down | ||
drop_table :projects_tags | ||
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,7 @@ | ||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
|
||
one: | ||
name: MyString | ||
|
||
two: | ||
name: MyString |
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,8 @@ | ||
require 'test_helper' | ||
|
||
class TagTest < ActiveSupport::TestCase | ||
# Replace this with your real tests. | ||
test "the truth" do | ||
assert true | ||
end | ||
end |