Lauro

Joined

6,740 Experience
24 Lessons Completed
5 Questions Solved

Activity

Posted in Using ActiveAdmin to Build an Admin UI Discussion

Yes!

Posted in JSON Web Tokens with Devise & Warden Discussion

I keep running into this error:

2.5.1 :004 > JsonWebToken.encode({sub: 1})
Traceback (most recent call last):
 2: from (irb):4
 1: from app/models/json_web_token.rb:4:in `encode'
TypeError (no implicit conversion of nil into String)

Any ideas on how I can debug this?

When exposing an image from ActiveStorage you first need to access :active_storage_blobs to expose:

      t.string   :key,        null: false
      t.string   :filename,   null: false
      t.string   :content_type
      t.text     :metadata
      t.bigint   :byte_size,  null: false
      t.string   :checksum,   null: false
      t.datetime :created_at, null: false

Then you can go into your API and expose the Json data the following way:
json.images @recipe.image.key

I'm trying to expose my API, but I'm having a hard time exposing an image that I uploaded using ActiveStorage. This is the current out put from the console when running Recipe.last.image:

 => #<ActiveStorage::Attached::One:0x00007fd502f47660 @name="image", @record=#<Recipe id: 10, user_id: 2, title: "Gin & Tonic", preparation: "New Recipe\r\nTitle\r\n\r\nGin & Tonic\r\nIngredients\r\n\r\nP...", ingredients: "New Recipe\r\nTitle\r\n\r\nGin & Tonic\r\nIngredients\r\n\r\nP...", created_at: "2018-07-24 18:54:49", updated_at: "2018-07-24 18:54:49">, @dependent=:purge_later>

How can I expose the actuall image URL when using ActiveStorage?

Posted in Direct Uploads with ActiveStorage - DO Spaces

I managed to up upload images to Digital Ocean's Spaces following the episode on Direct Uploads with ActiveStorage but I don't see the images on Digital Ocean's Spaces UI. How can I verify if I'm actually uploading the images to Spaces or ontro the droplet's disk? The link url to the images chances every couple of minutes.

Posted in Let's Encrypt Error on Hatch

I keep getting this error when trying to add Let's Encrypt using Hatch. Im not sure how to debug it.

Any thoughts?

Uploaded /etc/nginx/snippets/letsencrypt.conf

Uploaded /etc/nginx/snippets/ssl.conf

Executing 'add-apt-repository ppa:certbot/certbot'
 This is the PPA for packages prepared by Debian Let's Encrypt Team and backported for Ubuntu(s).
 More info: https://launchpad.net/~certbot/+archive/ubuntu/certbot
OK

Executing 'apt-get update'
Hit:1 http://apt.postgresql.org/pub/repos/apt xenial-pgdg InRelease
Hit:2 http://security.ubuntu.com/ubuntu xenial-security InRelease
Hit:3 http://mirrors.digitalocean.com/ubuntu xenial InRelease
Hit:4 http://ppa.launchpad.net/certbot/certbot/ubuntu xenial InRelease
Hit:5 http://mirrors.digitalocean.com/ubuntu xenial-updates InRelease
Hit:6 http://mirrors.digitalocean.com/ubuntu xenial-backports InRelease
Hit:7 https://deb.nodesource.com/node_7.x xenial InRelease
Hit:8 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu xenial InRelease
Get:10 https://dl.yarnpkg.com/debian stable InRelease [11.5 kB]
Hit:11 http://ppa.launchpad.net/git-core/ppa/ubuntu xenial InRelease
Get:12 https://repos.sonar.digitalocean.com/apt main/main amd64 Packages [1,172 B]
Err:12 https://repos.sonar.digitalocean.com/apt main/main amd64 Packages
  Hash Sum mismatch
Ign:13 https://oss-binaries.phusionpassenger.com/apt/passenger xenial InRelease
Hit:14 https://oss-binaries.phusionpassenger.com/apt/passenger xenial Release
Fetched 12.5 kB in 1s (10.1 kB/s)
Reading package lists...

E: Failed to fetch https://repos.sonar.digitalocean.com/apt/dists/main/main/binary-amd64/Packages.bz2  Hash Sum mismatch
E: Some index files failed to download. They have been ignored, or old ones used instead.


Hit:1 http://apt.postgresql.org/pub/repos/apt xenial-pgdg InRelease
Hit:2 http://security.ubuntu.com/ubuntu xenial-security InRelease
Hit:3 http://mirrors.digitalocean.com/ubuntu xenial InRelease
Hit:4 http://ppa.launchpad.net/certbot/certbot/ubuntu xenial InRelease
Hit:5 http://mirrors.digitalocean.com/ubuntu xenial-updates InRelease
Hit:6 http://mirrors.digitalocean.com/ubuntu xenial-backports InRelease
Hit:7 https://deb.nodesource.com/node_7.x xenial InRelease
Hit:8 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu xenial InRelease
Get:10 https://dl.yarnpkg.com/debian stable InRelease [11.5 kB]
Hit:11 http://ppa.launchpad.net/git-core/ppa/ubuntu xenial InRelease
Get:12 https://repos.sonar.digitalocean.com/apt main/main amd64 Packages [1,172 B]
Err:12 https://repos.sonar.digitalocean.com/apt main/main amd64 Packages
  Hash Sum mismatch
Ign:13 https://oss-binaries.phusionpassenger.com/apt/passenger xenial InRelease
Hit:14 https://oss-binaries.phusionpassenger.com/apt/passenger xenial Release
Fetched 12.5 kB in 1s (10.1 kB/s)
Reading package lists...


Command "apt-get update" returned exit code 100

Thanks Chris. Worked perfectly!

I forgot that Hatch sends an email with the deploy user's sudo password.

Im using commonmarker for the HTML::Pipeline::MarkdownFilter. And when trying to deploy my app, I get this exception:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/deploy/lauroio/shared/bundle/ruby/2.4.0/gems/commonmarker-0.16.7/ext/commonmarker
/home/deploy/.rbenv/versions/2.4.1/bin/ruby -r
./siteconf20170721-22951-szfhyg.rb extconf.rb
checking for cmake... no



[ERROR]: cmake is required and not installed. Get it here: http://www.cmake.org/


*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/deploy/.rbenv/versions/2.4.1/bin/$(RUBY_BASE_NAME)

How can I instal cmake?

Awesomeee! :D Let me try it out, I will let you know if I find a bug.

That's really awesome!

I'm really loving Hatch. Well done Chris!

I've been deploying several toy apps on the same server, but after I'm finished with them I would love to easily be available to delete them using Hatch's interface, instead of having to SSH into the server to delete the apps.

Is this a possible feature in the future?

Would love to have this feature on Hatch. :)

Posted in Turbolinks and jQuery compatibility on Rails 5

I see what you mean Anh. Thanks for the help!

I noticed that if the element with .use-different-card is an <a>, I needed to cancel the click event:

$('.use-different-card').on "click", (event) ->
  event.preventDefault()
  $(".card-on-file").hide()
  $(".card-fields").removeClass("hidden")

or

$('.use-different-card').on "click", ->
  $(".card-on-file").hide()
  $(".card-fields").removeClass("hidden")
  false

Posted in Turbolinks and jQuery compatibility on Rails 5

Hey Anh,

What do you mean in-line style? Where shoudl I add that?

I also tried adding:

  $(document).on 'turbolinks:before-visit', ->
  $('.use-different-card').on "click", ->
    $(".card-on-file").hide()
    $(".card-fields").removeClass("hidden")

Posted in Turbolinks and jQuery compatibility on Rails 5

I have a hidden field that's activated when clicked on the link using jQuery. When clicking on the link, the field appears just for a second and then disappears.

  $('.use-different-card').on "click", ->
    $(".card-on-file").hide()
    $(".card-fields").removeClass("hidden")

When I remove turbolinks, jQuery seems to work just fine.

I've tryied adding compatibility.coffee but I had no luck.

And using:

$(document).on "turbolinks:load", ->

This is my source tree.

//= require jquery
//= require jquery_ujs
//= require jquery.turbolinks
//= require turbolinks
//= require turbolinks-compatibility
//= require_tree .

Anything suggestion on what to try next?

Posted in Using React

Thanks Matthew,

I'll check out the book. And I'll start looking for a good read on resful rails development. :D

I will also check out the GoRails episodes on APIs.

Posted in Using React

Great question Melanie!

Hey Matthew do you have any resources that you would recoment that follows the same principal of having front end and back end decoupled?

Posted in What text editor are you using for GoRails Forum?

Thanks Jacob!

Awesome Chris! I will take a look.

Posted in What text editor are you using for GoRails Forum?

Hey Chris & Community! :)

What text editor are you using for the GoRails Forum post?

Im following the episode Markdown and Emoji with the html-pipeline gem. But im trying to add the top navbar to make it easier to add markdown for non-technical users.

Wow! Thanks for taking the time to answer. Always so helpful Chris! :grinning:

Posted in How can I subscribe a user when creating a new project?

Thanks Jack and Steve! After a couple of days, this code seeme to do the thick. But it seems abit smelly. What do you guys think? Can this be improved?

  def show
     begin
       @project = current_user.projects
         .joins(:subscriptions)
         .where(subscriptions: {user_id: current_user.id})
         .find(params[:id])
     rescue ActiveRecord::RecordNotFound => e
       redirect_to root_path, notice: 'No estas subscrito'
     end
   end
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.