8,330 Experience
0 Lessons Completed
10 Questions Solved


Ah, another typo—though you got it working, but for maintainability—a (possible) solution. @projects_id returns an object, while it needs an array. That line should be something like this: @projects_id = @projects.find(:project_id).pluck(:id) (which should return [1, 2, 3].

While above solution works, looks like you had a typo here:
@tasks = Project.where(:project_id => @projects_id).all

instead of @tasks = Task.where(:project_id => @projects_id).all

Posted in Expanding beyond a basic Rails CRUD site.

Some actual dev advice (dev platform and all): stick to Devise for authentication, don't waste your time bulding your own. Devise is tested throughout the years and the many gotchas you stumble upon are covered by using Devise. Mixed dev/bizz: stick to pure web developement for now, it's overwhelming enough already.

Posted in Expanding beyond a basic Rails CRUD site.

I can give you diferent types of advice (dev or bizz), going for the latter as that's what I would've wanted 10 years ago in this situation.
Don't overthink this. If you are working on your first app (assuming based on your post), don't even think about mobile now (nor Vue).
Think about what you want your product to really be and focus on just that and really nothing more.

More bizz-advice: do not build anything more than a simple blog where you can build an audience first based on useful articles about gin.

Posted in Routing for Admin area not working

You are currently using a form_with form helper and passing a model (@article). You can see in the actual source the link this creates. You can also pass an url to form_with, eg form_with url: admin_articles_path, method: :post do |f|. Which should do the "trick" here.

Posted in Attaching file to email Active Storage

Are using the correct url? So instead of blabla_path use blabla_url?

Posted in ruby on rails nested model relationship and routes

For 1. have a look at many-to-many relationship. With Rails this can be done like follows:
has_many: :country_sports
has_many: sports, through: :country_sports

has_many :country_sports
has_many :sports, through: :country_sports

belongs_to :sport
belongs_to :country

The last model is the one that connects the Sport and Country model and for the bare minimum only need country_id and sport_id.

For 2, you can nest the routes like follows:
resources :sports do
resources :country do
resources :leagues do
resources :matches

This is the gist of it, so feel free if you have specific issues with this.

From a quick glance all looks good. Any error? Does the log give you anything?


This is where a service object comes into play. This is a so called “Plain Old Ruby Object (PORO)” where you can put in specific code for one "job". You can then call this object from anywhere within your app (controller, other service object, etc.).
For me to good wrap my head around I searched from some howto's, read them, noted the best practices around them (eg. only one public method) and applied it to my own app.

Not sure if there is an episode about service objects on GoRails.

Your syntax seems to be off. Try something like this: :id, options_from_collection_for_select(@select, :id, :name)

Posted in How do I get past rails server error

cannot load such file -- sqlite3/sqlite3_native (LoadError)

This seems to be your best bet. Did you have sqlite installed?

Easiest way is to use a view helper and put the logic in there.

Something along the lines of:

def user_avatar(user_id)
    user = User.find!(user_id)
    if user.avatar.attached?
        image_tag user.avatar
        image_tag 'default_avatar.jpg'

Posted in NoMethodError in Contacts#edit

Is there any specific reason you adding the routes manually instead of using `resources :contacts` (this will make sure you get all the restful urls you need)? That should definitely fix your routing problems. 
If you keep to the conventions, Rails is easier to handle and doesn't give you headaches like this.

Posted in How to start and stop ngrok with Thin server?

Foreman is built for this. I use it to start rails, sidekiq and guard-rspec.

Install the gem, and add a Procfile(.dev)

web:    bundle exec thin start -p $PORT
worker: bundle exec rake resque:work QUEUE=*

Nothing more to add to above post from Jacob! 🙂
The easiest way is to run a cronjob to check the expiration date is in 30 days. If so, it sends an email. 
Let us know if you have specific issues implementing such thing.

Posted in How do I update?

Haven't looked at the YT vid, but based on your log, are you on correct page? `Rendering authors/posts/new.html.erb`
Check `rails routes` for the correct url, should look something like `edit_post`.
A typical Rails url would look like: `posts/<post_id>/edit`. 

The error about "Author doesn't exist" might have to do that you don't properly assign the Author to the post on create.

Posted in Rails stopped listening on localhost

What does the log say if you load the page in the browser?
Could you give some examples of Shopify links? Would be easier to give suggestions based on that.

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

© 2023 GoRails, LLC. All rights reserved.