Tom Dringer

Joined

2,690 Experience
12 Lessons Completed
1 Question Solved

Activity

Posted in Postgres issues

Hi,

So as i began a project earlier in the year, i decided to go full Docker for deployment. That was all good except debugging and stuff proved difficult so this weekend i decided to make the project native and use something for deployment.
Long story short, now i have gone back to a native based project (i.e no Docker), my Postgres installation (which was fine in the beginning) now just does not work.
I had issues with port numbers (which i have since managed to fix) and no issues with database not found. To make things worse, i think (i'm on macos and using Rubymine) i have Postgres installed via the OS, multiple versions by Homebrew, and some from standalone Postgres apps.
So obviously with these issues, i can;t start my app or run migrations etc.

Has anyone had this issue when moving away from Docker?

My error at the moment is no database named "xxx". I thought when i did i migration its all taken from the database.yml? I've run commands like rake db:create and similar.

I'm not totally sure the db i am connected to is even the right one.

Posted in Pretty urls with FriendlyID Discussion

Is it possible to to make the url "{id}-{user.fname}-{user.lname}"? It seems to work fine clicking on links, but as soon as i try to create, edit, or delete anything i get route not found.

Hi,

I want to validate my image upload field by making a user upload only a square image (i.e 200px x 200px). I'm basically wanting square image dimentions so it will resize and nicely and not look disproportional. Can this be done? Thanks

Posted in Share resources among controllers?

Anyone interested in this, in the news controller under def index you can just add the variable @students = Students.all or whatever and it really is as simple as that.

Posted in Share resources among controllers?

I'm thinking i need to look at Nested Resources?

Posted in Share resources among controllers?

Hi,

I’m not even sure I’m using the correct terminology here (sharing resources among controllers) but here goes.
Imagine I have a page called students with the usual CRUD functionality and another page with another controller called news or something. If the student page had a table called students with first name, second name etc ... how would I use the student table in the news template so I could do a for each student to list names or whatever? This is where things start to fall apart in my understanding of Rails. Thanks!

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

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2024 GoRails, LLC. All rights reserved.