Tom Dringer

Joined

2,210 Experience
9 Lessons Completed
1 Question Solved

Activity

Posted in Liking Posts Discussion

I am also having the 404 issue but it's something to do with routes i'm guessing?

ActionController::RoutingError (uninitialized constant Developments):

and then in the console:

POST http://localhost:3000/developments/1/like [HTTP/1.1 404 Not Found 1343ms]

When i run rake routes I get the following:

new_development_like GET /developments/:development_id/like/new(.:format) developments/likes#new

edit_development_like GET /developments/:development_id/like/edit(.:format) developments/likes#edit

development_like GET /developments/:development_id/like(.:format) developments/likes#show

PATCH /developments/:development_id/like(.:format) developments/likes#update
PUT /developments/:development_id/like(.:format) developments/likes#update
DELETE /developments/:development_id/like(.:format) developments/likes#destroy
POST /developments/:development_id/like(.:format) developments/likes#create

Any feedback is appreciated. Thanks!

Posted in Adding Javascript to Rails 6

Wow that really is above and beyond! Thank you so much!

Posted in Adding Javascript to Rails 6

Thanks for the feedback. I get the same error still, but this time much more detailed.


Uncaught ReferenceError: toastr is not defined
<anonymous> (index):38
dispatch turbolinks.js:75
notifyApplicationAfterPageLoad turbolinks.js:994
pageLoaded turbolinks.js:948
e turbolinks.js:872
start turbolinks.js:882
start turbolinks.js:1040
<anonymous> application.js:24
<anonymous> application-51d3c38d384dcac9fb08.js:2
Webpack 3
localhost:3000:38:5
<anonymous> (index):38
dispatch turbolinks.js:75
notifyApplicationAfterPageLoad turbolinks.js:994
pageLoaded turbolinks.js:948
e turbolinks.js:872
(Async: EventListener.handleEvent)
start turbolinks.js:882
start turbolinks.js:1040
<anonymous> application.js:24
<anonymous> application-51d3c38d384dcac9fb08.js:2

I have cleared my cache and all the usual things. Is there anything i should be looking out for in those errors?

I load my js in the head tag on my application layout file<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>

Thanks

Posted in Adding Javascript to Rails 6

Sure, so for example. I am trying to add Toastr. I have installed via Yarn.

In my javascript/packs/application.js I have require("toastr")

I also have an application_helper.rb which i saw from a tutorial about adding Toastr so i have:

def toastr_flash
    flash.each_with_object([]) do |(type, message), flash_messages|
      type = 'success' if type == 'notice'
      type = 'error' if type == 'alert'
      text = "<script>toastr.#{type}('#{message}', '', { closeButton: true, progressBar: true })</script>"
      flash_messages << text.html_safe if message
    end.join("\n").html_safe
  end

Then I call toastr_flash in my views/layouts/application.html.rb.

The error i get is Uncaught ReferenceError: toastr is not defined

Any direction is appreciated.

Posted in Adding Javascript to Rails 6

Hi. I am fairly new to Rails and so far I have been unsucessful at adding any JS to my Rails 6 project. I have seen many videos and tutorials but i seem to run in to the same issue. Basically I get "xxx is undefined" for every script. I'm thinking my scripts are called at the wrong time or in the wrong order. I'm using Webpacker for my JS. Thanks

Posted in Liking Posts Discussion

Hi newbie question: Will this work in a Rails 6 project? Thanks

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.