Stephen Sizer

Joined

3,140 Experience
11 Lessons Completed
1 Question Solved

Activity

Posted in Webpack and Purge CSS

Hi All,

I am trying to purge my css as I am using tailwind as outlined in the video Chris did. I'm getting an error.

postcss.config.js
let environment = {
plugins: [
require('tailwindcss'),
require('autoprefixer'),
require('postcss-import'),
require('postcss-flexbugs-fixes'),
require('postcss-preset-env')({
autoprefixer: {
flexbox: 'no-2009'
},
stage: 3
}),
require('@fullhuman/postcss-purgecss')({
content: [
'./app//*.html.erb',
'./app/helpers/
/.rb',
'./app/javascript/
/.js',
'./app/javascript//*.vue',
'./app/javascript/
/*.jsx',
],
defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || []
})
]
}

module.exports = environment

tailwind.config.js

const defaultTheme = require('tailwindcss/defaultTheme')

module.exports = {
purge: [],
theme: {
extend: {
colors: {
blue: {
'100': '#D8F0F9',
'200': '#B1E1F4',
'300': '#8AD2EF',
'400': '#63C3EA',
default: '#3CB5E5',
'600': '#36A2CE',
'700': '#3090B7',
'800': '#2A7EA0',
'900': '#246C89',
},
},
},
},
variants: {
textColor: ['responsive', 'hover', 'focus', 'visited', 'disabled'],
backgroundColor: ['responsive', 'hover', 'focus', 'active', 'disabled'],
borderColor: ['responsive', 'hover', 'focus', 'active', 'disabled'],
},
plugins: [],
}

Error:

ERROR in ./node_modules/emoji-mart/css/emoji-mart.css (./node_modules/css-loader/dist/cjs.js??ref--6-1!./node_modules/postcss-loader/src??ref--6-2!./node_modules/emoji-mart/css/emoji-mart.css)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
TypeError: Invalid PostCSS Plugin found at: plugins[5]

(@/Users/stephensizer/Workspace/coach-rx/postcss.config.js)
at /Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/plugins.js:72:15
at Array.forEach ()
at plugins (/Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/plugins.js:58:13)
at processResult (/Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/index.js:33:14)
at /Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/index.js:94:14
@ ./node_modules/emoji-mart/css/emoji-mart.css 2:26-138
@ ./app/javascript/src/components/Conversations/Conversation/Conversation.js
@ ./app/javascript/src/store/reducers/conversations.js
@ ./app/javascript/packs/index.jsx

ERROR in ./node_modules/react-dates/lib/css/_datepicker.css (./node_modules/css-loader/dist/cjs.js??ref--6-1!./node_modules/postcss-loader/src??ref--6-2!./node_modules/react-dates/lib/css/_datepicker.css)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
TypeError: Invalid PostCSS Plugin found at: plugins[5]

(@/Users/stephensizer/Workspace/coach-rx/postcss.config.js)
at /Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/plugins.js:72:15
at Array.forEach ()
at plugins (/Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/plugins.js:58:13)
at processResult (/Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/index.js:33:14)
at /Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/index.js:94:14
@ ./node_modules/react-dates/lib/css/_datepicker.css 2:26-145
@ ./app/javascript/src/components/Planning/ShortTermPlanForm/ShortTermPlanForm.js
@ ./app/javascript/src/components/Planning/Planning.js
@ ./app/javascript/src/router/Index.js
@ ./app/javascript/src/components/App.js
@ ./app/javascript/packs/index.jsx

ERROR in ./node_modules/tippy.js/dist/tippy.css (./node_modules/css-loader/dist/cjs.js??ref--6-1!./node_modules/postcss-loader/src??ref--6-2!./node_modules/tippy.js/dist/tippy.css)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
TypeError: Invalid PostCSS Plugin found at: plugins[5]

(@/Users/stephensizer/Workspace/coach-rx/postcss.config.js)
at /Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/plugins.js:72:15
at Array.forEach ()
at plugins (/Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/plugins.js:58:13)
at processResult (/Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/index.js:33:14)
at /Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/index.js:94:14
@ ./node_modules/tippy.js/dist/tippy.css 2:26-133
@ ./app/javascript/src/components/Client/ClientSidebar/ClientSidebar.js
@ ./app/javascript/src/hoc/coach_layouts/ClientLayout/ClientLayout.js
@ ./app/javascript/src/router/Index.js
@ ./app/javascript/src/components/App.js
@ ./app/javascript/packs/index.jsx

ERROR in ./node_modules/react-images-upload/index.css (./node_modules/css-loader/dist/cjs.js??ref--6-1!./node_modules/postcss-loader/src??ref--6-2!./node_modules/react-images-upload/index.css)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
TypeError: Invalid PostCSS Plugin found at: plugins[5]

(@/Users/stephensizer/Workspace/coach-rx/postcss.config.js)
at /Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/plugins.js:72:15
at Array.forEach ()
at plugins (/Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/plugins.js:58:13)
at processResult (/Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/index.js:33:14)
at /Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/index.js:94:14
@ ./node_modules/react-images-upload/index.css 2:26-127
@ ./node_modules/react-images-upload/compiled.js
@ ./app/javascript/src/components/Account/Info/Info.js
@ ./app/javascript/src/components/Account/Account.js
@ ./app/javascript/src/router/Index.js
@ ./app/javascript/src/components/App.js
@ ./app/javascript/packs/index.jsx

ERROR in ./app/javascript/stylesheets/application.scss (./node_modules/css-loader/dist/cjs.js??ref--7-1!./node_modules/postcss-loader/src??ref--7-2!./node_modules/sass-loader/dist/cjs.js??ref--7-3!./app/javascript/stylesheets/application.scss)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
TypeError: Invalid PostCSS Plugin found at: plugins[5]

(@/Users/stephensizer/Workspace/coach-rx/postcss.config.js)
at /Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/plugins.js:72:15
at Array.forEach ()
at plugins (/Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/plugins.js:58:13)
at processResult (/Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/index.js:33:14)
at /Users/stephensizer/Workspace/coach-rx/node_modules/postcss-load-config/src/index.js:94:14
@ ./app/javascript/stylesheets/application.scss 2:26-228
@ ./app/javascript/packs/application.js

Is there a way to check to see if the notification already exists before adding another as I'm getting a lot of duplicates.

Posted in Action Mailbox Routes

@chris Legend!! Thanks sir!

Posted in Action Mailbox Routes

I'm adding action mailbox to my Rails + React app, the problem I'm having is that the mounted routes are at the very bottom of the routes file so it will not get called due to the fact that I need a catch all for my react app.

Is there a way to move the mailbox routes to the top of the file?

Posted in User model guidance

Hi All,

I'm creating a coaching app and have two users that use the system a coach and a client. A coach can also be a client of another coach. So I will need to be able to switch accounts to either the client or the coach.

Coach:
has_many :clients

Client:
belongs_to :coach

What would be the best way to do this? Having two Devise models Coach and Client or having two boolean fields on the user to say is_coach, and is_client.

If a coach has an account and then is added as a client, I want that client account to have the same password as the coach account for ease of use.

Thanks,
Stephen

Posted in Announcements

Hi Chris,

How do you do the announcements in Hatchbox?

Thanks,
Steve

Posted in Plan limits

I'm currently building a sass product that has three plans beginner, intermediate and advanced. This is then linked to a stripe subscription product.

Each plan has limits eg. the number of team members they can add, the number of projects they can create.

Whats the best way to handle the plan limits?

Posted in File uploads in Rails with Shrine Discussion

has anyone used Shrine and Backblaze B2 storage?

What is the syntax for querying a boolean value?

Trying the below doesn't seem to work? and throws the following error:

PG::UndefinedFunction: ERROR: operator does not exist: text = boolean

current_user.companies.where("holiday_request_settings ->> :key = :value", key: "enable_holiday_requests", value: true)

If I try the following I get no results:

current_user.companies.where("holiday_request_settings ->> :key = :value", key: "enable_holiday_requests", value: "true")

The company current has the following data:

holiday_request_settings: {"enable_holiday_requests"=>true, "holiday_allowance_days"=>20}

This is the code on the model:

typed_store :holiday_request_settings, coder: JSON do |s|
        s.boolean :enable_holiday_requests, default: false
        s.integer :holiday_allowance_days
end

Any ideas?

Posted in How do I work out time slots greater than 5 hours

Thanks Chris

Posted in How do I work out time slots greater than 5 hours

I have a booking application where you can book time against a room. I need a way to find where it is booked for more than 5 hours consecutively to do some reporting.

This can be anytime over a 24 hour period.

So for example it might be booked

Monday
8:00am - 10:00am (2 hours)
10:00am - 13:30pm (3.5 hours)

This should be classed as over 5 hours consecutively.

There could be an occasion where it would be booked like this:

Monday
10:00pm - 12:00am (2 hours)
Tuesday
12:00am - 4:00am (4 hours)

Again this is over 5 hours consecutively

My Models are the following (simplified):

Room

  • has_many timeslots

TimeSlot

  • start_time (:date_time)
  • end_time (:datetime)

I am currently looping through each day of the week and looping through each time slot for that day and then checking to see if start_time == end_time of the next slot to work out if it is consecutive. Not sure if this is the easiest way or if there is something more obvious that would do what I need.

Your help is really appreciated.

Posted in Devise Masquerade with multiple Devise User Models

Hi All,

Has anyone used devise masquerade before with multiple devise models. I have and Admin model and a User model.

I'm having issues and when I try implementing it, I can't seem to login as another user.

Thanks in advance.

Posted in Deliver Later not working

Hi Guys,

I have a rails app, and for some reason when I call deliver_later the emails aren't sending. When I test it with deliver_now it works fine.

I have redis and sidekiq both running.
TID-owqrlmxrh ActionMailer::DeliveryJob JID-10b51cc7e7b76d99307add2c INFO: start

the above shows it goes to the queue but never sends. Any help would be much appreciated before I pull my hair out.

I have written two system tests for my current application and I have now hit a road block.

test "visiting the timesheet index without signing in" do
    visit timesheets_path

    assert_text "You need to sign in or sign up before continuing."
  end

  test "visiting the timesheet index (signing in first)" do
    visit new_user_session_path

    fill_in "Email address", with: "[email protected]"
    fill_in "Password", with: "password"

    click_on "Log in"

        assert_text "Signed in successfully."
  end

The second test is failing due to not being able to load a font shown below:

Error:
ContractorTimesheetsTest#test_visiting_the_timesheet_index_(signing_in_first):
ActionController::RoutingError: No route matches [GET] "/fonts/fa-solid-900.woff2"

If I spin up my rails server locally I have no errors for missing resources and my font files are all loaded correctly.

For further reference I am using the defaults for my application system test case

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
  driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
end

Does anyone have any suggestions?

Posted in Rails Webpack caching

Found the issue! It was due to my environment file in webpacker causing the assets to not be recompiled.

Posted in Rails Webpack caching

I'm having an issue in development where I've changed my main application.js file in /javascript/packs/ and the file is being cached so having a hard time testing new changes. Does anyone else have this issue?

Thanks,
Steve

Posted in How to add an image to prawn pdf?

I'm wondering how to add an image to a prawn pdf from active storage. I've tried a number of ways and can't seem to get it to render.

Thanks in advance,
Steve

Posted in Regex getting hashtags

I'm wanting to capture all hastags from the richtext field. I thought I had a solution until I came across testing where the richtext editor put HTML entites into the markup.

/#([\w]+)/
<p>#ruby you&#39;re amazing</p>

so at the moment its getting #ruby, #39 any help would be appreciated.

thanks,
Steve

Posted in Attaching file to email Active Storage

Changed to _url and not get this error:

Unsupported argument type: ActiveStorage::Attached::One
Extracted source (around line #35):

def send_notifications
AssignmentMailer.notify_user(user).deliver_later
-- AssignmentMailer.notify_team(user, upload).deliver_later ---
end
end

Posted in Attaching file to email Active Storage

Hi Guys,

I am trying to attach a pdf to an email via active storage. Here is my code below and the error I am getting.

class Assignment < ApplicationRecord
has_one_attached :upload
belongs_to :user
belongs_to :course
belongs_to :lesson

after_save :send_notifications

def send_notifications
AssignmentMailer.notify_user(user).deliver_later
AssignmentMailer.notify_team(user, upload).deliver_later
end
end

ERROR:
No such file or directory @ rb_sysopen - /rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBFQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889c8cda6fbfb3c827ff5bcd7a4ca7ff1594a37e/weekend.pdf

Thanks,
Steve

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.