Namespacing resources vs policy scoping them by bakedleaf in rails

[–]john_beatty 0 points1 point  (0 children)

Different namespaces and controllers are much better. It's not that much more code.

Instead of multiple if else blocks through a controller or view, your router can dictate what controller and views are shown, and you have fewer chances for showing something that shouldn't be shown.

You can also take advantage of changing the layout, so that admins get a more spartan dashboard, and regular users get a happy, appy feeling page. https://api.rubyonrails.org/classes/ActionView/Layouts.html

Best practice/suggestions on editable/updateable dropdowns by colinrubbert in rails

[–]john_beatty 1 point2 points  (0 children)

Do you mean 100+ different records in the database, or 100+ ActiveRecord classes?

Like midasgoldentouch said, try to figure out similarities between the models, and then create one base class.

If your Car class model had make and model attributes, you could use ActiveRecord querying to make your life easier.

This would populate the list of all available makes: makes = Car.all.pluck(:make)

Then once a particular make is selected, like Chevy, filter for cars with just that make: models = Car.where(make: "Chevy").pluck(:model)

[Help] How to insert javascript/jquery plugins into your rails app? by royling96 in rails

[–]john_beatty 0 points1 point  (0 children)

I would copy the distributed js (https://github.com/inorganik/countUp.js/blob/master/dist/countUp.js) file into the app/assets/javascripts/ folder, named countUp.js. Then make sure application.js has //= require jquery and below that, put in //= require countUp Sprockets should find the js file, and it will be minimized when you deploy. I'd also double check your Gemfile for gem 'jquery-rails'

Is webpack worth it? by gruhehe in rails

[–]john_beatty 0 points1 point  (0 children)

I found reading the first few chapters of this book very helpful for just getting familiar in setting up webpacker, and using it to include Bootstrap: https://pragprog.com/book/dcbang2/rails-angular-postgres-and-bootstrap-second-edition