Activity
I would recommend Rails's ActiveStorage. I've done some episodes on it which you can checkout, but it's the official Rails file uploading library and definitely the easiest.
You'll still need to have imagemagick installed. They all use this for the actual cropping and resizing of images.
Carrierwave works too, but it requires some other setup like creating Uploaders so you can define how a file gets processed.
ActiveStorage works a bit different where you define how the file gets resized when you use it in your view. Carrierwave does this as soon as the file is uploaded instead. Both have some advantages but ActiveStorage should definitely be easier.
You can pass subdomain: nil
into your url helpers to change the subdomain. Something like link_to home_url(subdomain: nil)
Posted in Rails Application Templates Discussion
Hey Mark, I just fixed that. Just need to modify the navbar link to use "#"
instead of root_path
. https://github.com/excid3/jumpstart/commit/7a49c0fe5cbbd3621288cb00b9ca390099d869a9
Dropdown is fixed now. Just change the root_path
in the link_to
for the dropdown navbar.html.erb to "#"
.
All the navigation is in app/views/shared/navbar.html.erb
👍
Hey Damian!
It's usually easiest to set that up in your routes file. You can setup a subdomain constraint so that when the subdomain is www or nil, you can render the homepage. Otherwise when there's a subdomain, you can send it to the account controller.
You can put this in app/lib/account_subdomain.rb
class AccountSubdomain
def self.matches? request
# www and no subdomain are excluded and don't count as account subdomains
# You can add any more subdomains to this array to have them ignored.
!["www", nil].include? request.subdomain
end
end
Then your config/routes.rb
file can use this to set the constraints:
Rails.application.routes.draw do
# Account routes
constraints(AccountSubdomain) do
root to: "account#index"
end
root to: "home#index"
end
It's your standard bootstrap dropdown, so double check and make sure there are no JS errors in the browser console.
I'm not at the computer right now, but I can take a look tomorrow hopefully.
Great! Let us know how it goes. I'm online a bit more during the week (and after the holidays) so sorry for the late replies.
My personal advice is generally to build it from scratch so you can understand how it works in-depth. And if you realize it'll be too much work, then using the apartment gem can help save you some time.
Hey Damian,
Like the error says, looks like you'll need to run "rails webpacker:install"
/home/meaw/.rvm/gems/ruby-2.5.1/gems/webpacker-3.5.5/lib/webpacker/configuration.rb:79:in `rescue in load': Webpacker configuration file not found /home/meaw/work/weepx/two/weepx/config/webpacker.yml. Please run rails webpacker:install Error: No such file or directory @ rb_sysopen - /home/meaw/work/weepx/two/weepx/config/webpacker.yml (RuntimeError)
Jumpstart does that for you automatically, so you shouldn't have to, but maybe something failed when you created it originally.
Sounds like something is killing the web process. What happens if you just run rails s
instead of foreman?
Hey Damin,
You can handle subdomains from scratch like so: https://gorails.com/episodes/subdomains-and-multi-tenancy-from-scratch?autoplay=1
An alternative is to let the Apartment gem do it for you. Covered that here, they have a subdomain option as well. https://gorails.com/episodes/multitenancy-with-apartment?autoplay=1
You'll have to set your DNS to redirect *.website.com
to your server for this to work.
Yep! You can do it with a Rails application template like the one I built called Jumpstart: https://github.com/excid3/jumpstart
This episode talks about how to build your own: https://gorails.com/episodes/rails-application-templates
You'd just copy over all your code into a template and use it every time you create a new app.
When you <%= render comment.comments
, it isn't specifying any order, so you'd want to sort that by created_at if you want them in a particular order. A SQL query doesn't respect any ordering unless you tell it to.
<%= render comment.comments.order(created_at: :asc)
The episode comments are also forum threads, so let me know if you still have issues. I need to go through the forum code some more and polish it up again. It got overrun a bit by spammers before so I've been trying to get it back in order.
Actually, I don't see your other comment. Hmmm! That's weird.
It probably got marked as spam. I'll check the comments and unmark it for ya.
Posted in Video request: using message_bus gem
I've had this on my todo list for a while now and just haven't had the time to explore it properly so I can make a screencast. I'll have to do this soon.
What's the reason it doesn't work with Capistrano 3? Rails 5.2.1.1 has an important security fix that you'll want to get running in production as soon as possible so your server doesn't get hacked.
Posted in Suggestion for a new episode
Great idea! And yes, I would do a cron job. It'd query for maybe like the top 10 posts of the week, or whatever content you want to display. Then just pass that into a mailer and send those out.