-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add user_id to tools, set up associations and factories, and annotate gem * tool index with user contact info
- Loading branch information
Showing
14 changed files
with
177 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
|
||
class ToolsController < ApplicationController | ||
def index | ||
@tools = Tool.all | ||
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 |
---|---|---|
@@ -1,4 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
class Tool < ApplicationRecord | ||
belongs_to :user | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: tools | ||
# | ||
# id :integer not null, primary key | ||
# brand_name :string | ||
# description :text | ||
# name :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# user_id :integer not null | ||
# |
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 |
---|---|---|
@@ -1 +1,22 @@ | ||
<div class="text-3xl font-bold">Tools</div> | ||
<div class="flex flex-col mx-auto w-3/4 gap-4"> | ||
<div class="text-3xl font-bold">Tools</div> | ||
<table class='w-full'> | ||
<thead class='text-left'> | ||
<tr> | ||
<th class='p-2 border border-slate-700'>Tool Name</th> | ||
<th class='p-2 border border-slate-700'>Tool Brand</th> | ||
<th class='p-2 border border-slate-700'>Owner Contact</th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @tools.each do |tool| %> | ||
<tr> | ||
<td class='border border-slate-700 p-2'><%= tool.name %></td> | ||
<td class='border border-slate-700 p-2'><%= tool.brand_name %></td> | ||
<td class='border border-slate-700 p-2 underline'><%= mail_to tool.user.email %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</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,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddUserIdToTools < ActiveRecord::Migration[7.1] | ||
def change | ||
add_column :tools, :user_id, :integer, null: false | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,61 @@ | ||
# frozen_string_literal: true | ||
|
||
# NOTE: only doing this in development as some production environments (Heroku) | ||
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper | ||
# NOTE: to have a dev-mode tool do its thing in production. | ||
if Rails.env.development? | ||
require 'annotate' | ||
task :set_annotation_options do | ||
# You can override any of these by setting an environment variable of the | ||
# same name. | ||
Annotate.set_defaults( | ||
'active_admin' => 'false', | ||
'additional_file_patterns' => [], | ||
'routes' => 'false', | ||
'models' => 'true', | ||
'position_in_routes' => 'before', | ||
'position_in_class' => 'after', | ||
'position_in_test' => 'before', | ||
'position_in_fixture' => 'before', | ||
'position_in_factory' => 'before', | ||
'position_in_serializer' => 'before', | ||
'show_foreign_keys' => 'true', | ||
'show_complete_foreign_keys' => 'false', | ||
'show_indexes' => 'true', | ||
'simple_indexes' => 'false', | ||
'model_dir' => 'app/models', | ||
'root_dir' => '', | ||
'include_version' => 'false', | ||
'require' => '', | ||
'exclude_tests' => 'true', | ||
'exclude_fixtures' => 'false', | ||
'exclude_factories' => 'false', | ||
'exclude_serializers' => 'false', | ||
'exclude_scaffolds' => 'true', | ||
'exclude_controllers' => 'true', | ||
'exclude_helpers' => 'true', | ||
'exclude_sti_subclasses' => 'false', | ||
'ignore_model_sub_dir' => 'false', | ||
'ignore_columns' => nil, | ||
'ignore_routes' => nil, | ||
'ignore_unknown_models' => 'false', | ||
'hide_limit_column_types' => 'integer,bigint,boolean', | ||
'hide_default_column_types' => 'json,jsonb,hstore', | ||
'skip_on_db_migrate' => 'false', | ||
'format_bare' => 'true', | ||
'format_rdoc' => 'false', | ||
'format_yard' => 'false', | ||
'format_markdown' => 'false', | ||
'sort' => 'false', | ||
'force' => 'false', | ||
'frozen' => 'false', | ||
'classified_sort' => 'true', | ||
'trace' => 'false', | ||
'wrapper_open' => nil, | ||
'wrapper_close' => nil, | ||
'with_comment' => 'true' | ||
) | ||
end | ||
|
||
Annotate.load_tasks | ||
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 |
---|---|---|
|
@@ -2,10 +2,12 @@ | |
|
||
FactoryBot.define do | ||
factory :user do | ||
|
||
email { '[email protected]' } | ||
password { 'catnip' } | ||
end | ||
|
||
factory(:tool) do | ||
association :user | ||
name { 'Hammer' } | ||
brand_name { 'Makita' } | ||
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe User, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
it 'has a valid factory' do | ||
expect(build(:user)).to be_valid | ||
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