Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back-End Engineering Intern Assessment #202

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/models/article.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#based off of the structure of the unit test article_test.rb,
#I'm creating an article class within the app/models directory
#that inherits from ActiveRecord::Base
#This is the class that will be used to create new articles
#in the database
class Article < ActiveRecord::Base
#Next, I need to add search functionality to this Article class. We can do this by using a method.
def self.search(query)
where("title LIKE ? OR content LIKE ?", "%#{query}%", "%#{query}%")
end
end
10 changes: 10 additions & 0 deletions db/migrate/20240128165415_create_articles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#creating a table in the database called create articles
class CreateArticles < ActiveRecord::Migration[6.0]
def change
create_table :articles do |t|
t.string :title
t.text :body
t.timestamps
end
end
end
6 changes: 6 additions & 0 deletions db/migrate/20240128170026_add_content_to_articles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Adding in the content column to the articles table
class AddContentToArticles < ActiveRecord::Migration[7.1]
def change
add_column :articles, :content, :text
end
end
6 changes: 6 additions & 0 deletions db/migrate/20240128170211_add_author_to_articles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#adding in author column to articles table
class AddAuthorToArticles < ActiveRecord::Migration[7.1]
def change
add_column :articles, :author, :string
end
end
6 changes: 6 additions & 0 deletions db/migrate/20240128170422_add_date_to_articles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#adding in date column to articles table
class AddDateToArticles < ActiveRecord::Migration[7.1]
def change
add_column :articles, :date, :datetime
end
end
24 changes: 24 additions & 0 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading