Simon Cooper

Joined

3,410 Experience
5 Lessons Completed
3 Questions Solved

Activity

Posted in Expanding beyond a basic Rails CRUD site.

Ok so I've only just read in to JWT. Seems using the Knock gem, this might be the best way for me to authorise users based on my own user model, espeically as it appears it will also be suitable for mobile app too.

Posted in Expanding beyond a basic Rails CRUD site.

So I've got a fairly basic CRUD style rails app, which has a list of Gins, Distilleries and and blog Posts.

I'd like to expand it quite significantly in the following ways:

  • Add authenticated users To allow users to interacat with Gins. e.g. be able to favorite, add to wish list, rate and gamification etc
  • Add a user dashboard The dashboard would display the above interactions, and also a feed of all users interactions
  • Build native mobile apps I hear mobile is the future ;) but to also allow for the below:
  • User uploads of gin photos I want to have a monthly activity where users have to find gins based on some hints, and they can then upload the gins that they find.

So, this has really got my head aching, and feels wayyyyyy beyond my capabilities, but hey...

I have some main questions:

  1. What can I use for user authentication, so that a user can login in to the app, and also web clients? Good ole' Devise? Google Firebase, AWS Cognito, Oauth perhaps Okta.

  2. If I use something other than Devise, how and where would I store the user data for likes for example that a user might make in the web client and/or the mobile app.

  3. I'd like to keep 'standard' rails app for my static pages and the blog, (so easy to do in rails, plus SEO advantages) but am thinking of building a seperate VueJS app for the dashboard. I would render Gin and Distilleries in json API, which could also be access via the mobile apps.

Appreciate this is a big quetsion, and will have many opnions, but any thoughts or comments would be appriciated as my brain hurts and my girlfriend doesn't care to be a soundboard.

Old post I know but it's quite a general question so will add my thoughts.

My decision making has always come down to whether there will only ever be one category, or potential multiple categories. For the singular, you can probably just add a column in your model, but for multiple entries, you might want to create a seperate category model, and then reference the two via a joins table.

This approach is very common for tags for example, but to be honest, I've started using it in many areas that can have multiple entries. e.g. flavours in coffee or different gin brands served by a bar.

At the end of the day, it's all just a type of tagging.

Posted in Facets with Searchkick

@Caio. Your code just helped me out too. Thanks,

Posted in Having some Issues regarding Rails 5.2 upgrade

Have you ran $ rails active_storage:install which generates a migration to add the two new tables active_storage_attachments and active_storage_blobs? You'll of course also need to then run $ rails db:migrate.

Posted in Reputation Gems - Merit

I was looking at reputation gems, and it seems Merit could be a good choice.

Quick Question though, can you add this to existing User models? Or does it need to generate it's own?

From their guides:
rails g merit MODEL_NAME (e.g. user). This creates a migration and adds has_merit to MODEL_NAME.

Posted in Login with Facebook Discussion

That's a very interesting article, and also the one referenced within in. I hadn't thought too much about it making sites look like the side of a Nascar. Either way, I think I'll leave it out of my sign_up process for the time being.

Posted in Two Factor Authentication With Devise Discussion

I've had that issue before when copying code from Medium for example. You get in the habit of looking for it after a while, but it does also highlight it can be better to write out the code which helps you to understand it opposed to just copy and pasting.

Posted in Login with Facebook Discussion

With more and more concerns over the security and usage of user data at Facebook, does anyone have second thoughts about providing Facebook as an option?

I have an app I've just updated to Rails 5.2 and migrated away from Paperclip for image uploads to S3 to the new ActiveStorage feature.  I am able to display some uploaded photos I did with the html version of the site, but I don't know how to access the Blob via VueJS to display the images in the database.  That then also leads me to the second question here, what would be the best way to upload images through a VueJS front end?  Would I continue to try and use Active Storage, or would I swap to something like http://www.dropzonejs.com/ ?

Posted in Using Webpacker and Rails on AWS Elastic Beanstalk

Solved it ;)

Moved tailwaindcss to dependencies instead of devDependencies in package.json

Posted in Using Webpacker and Rails on AWS Elastic Beanstalk

I spoke too soon.  The issue is back:

Module build failed: Error: Loading PostCSS Plugin failed: Cannot find module 'tailwindcss'

Can't work this out.  Starting to think it's too much hassle.  

Ok so a few things spring to mind:
  1. Have you migrated the additional columns to your user model?  e.g. 'provider', 'uid'?
  2. Have you also added your app details in config/initializers/devise.rb?
    1. config.omniauth :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'], scope: "email", info_fields: 'email, first_name, last_name'

Posted in Using Webpacker and Rails on AWS Elastic Beanstalk

SOLVED IT:

Just needed to run:

eb setenv RAILS_SERVE_STATIC_FILES=enabled

Posted in Using Webpacker and Rails on AWS Elastic Beanstalk

Good point.  

I'm getting a 404 on both the application.css and application.js

application-a5cbbd551a90e5fa75fc8997e17a9236.css Failed to load resource: the server responded with a status of 404 (Not Found)

Posted in Using Webpacker and Rails on AWS Elastic Beanstalk

yeah everything is fine locally.  I've just tried this, and whilst it seems to compile locally, I've ran eb deploy with no errors, but the live app still has not CSS styling. 

Looks like it did compile, as I'm not getting this error in the logs:


 ERROR in ./node_modules/css-loader??ref--1-2!./node_modules/postcss-loader/lib??ref--1-3!./app/javascript/css/application.css
Module build failed: Error: Loading PostCSS Plugin failed: Cannot find module 'tailwindcss'

Posted in Using Webpacker and Rails on AWS Elastic Beanstalk

Hey Ryan,

I've managed to do a successful deploy to beanstalk with the following in `.ebextensions`.  Although I have no CSS styling in the production app. One step forwards! 

commands:
  01_install_yarn:
    command: "sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo && curl --silent --location https://rpm.nodesource.com/setup_6.x | sudo bash - && sudo yum install yarn -y"
  02_download_nodejs:
    command: curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
  03_install_nodejs:
    command: yum -y install nodejs



Posted in Using Webpacker and Rails on AWS Elastic Beanstalk

Can anyone point me in the direction of documentation/tutorial for using Webpacker with Rails on Elastic Beanstalk? I have been playing with Tailwind CSS (which is great btw), and I'm getting a version requirement error when trying to upload:

Webpacker requires Node.js >= 6.0.0 and you are using 4.6.0

Does anyone know where/how I can upgrade my Node version?

Anyone finding application.css is not found in the webpacker manifest.json?

Module not found: Error: Can't resolve '../css/application.css'

Posted in Add image attachment to user post and server via AWS S3

Hey Martin.  I ended up just using Paperclip, in a regular erb view.  Very much does what I need for now.
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

© 2020 GoRails, LLC. All rights reserved.