Skip to content

Commit

Permalink
fixed some problems from switching environments and changed an attrib…
Browse files Browse the repository at this point in the history
…ute name
  • Loading branch information
mikedao committed Jun 4, 2023
1 parent 7696321 commit 19d8025
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]
gem "pry"
gem "factory_bot_rails"
gem "faker"
end

group :test do
Expand Down
9 changes: 9 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ GEM
diff-lcs (1.5.0)
docile (1.4.0)
erubi (1.12.0)
factory_bot (6.2.1)
activesupport (>= 5.0.0)
factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0)
railties (>= 5.0.0)
faker (3.2.0)
i18n (>= 1.8.11, < 2)
ffi (1.15.5)
globalid (1.1.0)
activesupport (>= 5.0)
Expand Down Expand Up @@ -246,6 +253,8 @@ DEPENDENCIES
bootsnap
capybara
debug
factory_bot_rails
faker
image_processing (~> 1.2)
importmap-rails
jbuilder
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/campaigns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ def destroy

private
def campaign_params
params.require(:campaign).permit(:title, :description, :image_link)
params.require(:campaign).permit(:title, :description, :image_url)
end
end
2 changes: 1 addition & 1 deletion app/views/admin/campaigns/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class='campaigns'>
<% @campaigns.each do |campaign| %>
<div id="<%= campaign.title.parameterize %>">
<p><%= image_tag campaign.image_url %></p>
<p><%= image_tag campaign.image_url if campaign.image_url %></p>
<p><h2><%= campaign.title %></h2></p>
<p><%= campaign.description %></p>
<p><%= link_to "Details", admin_campaign_path(campaign) %></p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/dashboard/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class='campaigns'>
<% @campaigns.each do |campaign| %>
<div id="<%= campaign.title.parameterize %>">
<p><%= image_tag campaign.image_link %></p>
<p><%= image_tag campaign.image_url %></p>
<p><h2><%= campaign.title %></h2></p>
<p><%= campaign.description %></p>
<p><%= link_to "Details", admin_campaign_path(campaign) %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/welcome/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class='campaigns'>
<% @campaigns.each do |campaign| %>
<div id="<%= campaign.title.parameterize %>">
<p><%= image_tag campaign.image_link %></p>
<p><%= image_tag campaign.image_url %></p>
<p><h2><%= campaign.title %></h2></p>
<p><%= campaign.description %></p>
<%= link_to "View Campaign", campaign_path(campaign) if current_user %>
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20230602145506_create_campaigns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class CreateCampaigns < ActiveRecord::Migration[7.0]
def change
create_table :campaigns do |t|
t.string :title
t.string :image_link
t.string :image_url

t.timestamps
# ! This migration also creates a rich text field called description
Expand Down
2 changes: 1 addition & 1 deletion db/schema.rb

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

2 changes: 1 addition & 1 deletion spec/factories/campaign.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
factory :campaign do
title { "#{Faker::Cosmere.surge}-#{Faker::Cosmere.surge}-#{Faker::Number.hexadecimal(digits: 4)}" }
description { Faker::Quotes::Shakespeare.hamlet_quote + Faker::Number.hexadecimal(digits: 4) }
image_link { Faker::Placeholdit.image }
image_url { Faker::Placeholdit.image }
end
end
3 changes: 3 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
rescue ActiveRecord::PendingMigrationError => e
abort e.to_s.strip
end

require 'factory_bot_rails'

RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
Expand Down

0 comments on commit 19d8025

Please sign in to comment.