Chris Oliver

Joined

292,890 Experience
93 Lessons Completed
295 Questions Solved

Activity

Posted in Upload Progress with Refile Javascript Discussion

That's actually how it's supposed to work actually because it provides you the ability to generate different image sizes on the fly. The downside to this is it requires you to setup a CDN so that it doesn't have to generate the image every single request. You can check out the readme for some more information on that.

Posted in subscribe if old one month user

Thanks for the heads up! I'll take a look and see what's up!

Posted in Deploying To Production on Heroku with Puma Discussion

That's great to hear!

Posted in Deploying To Production on Heroku with Puma Discussion

Heroku really only recommends the two lines for url and pool. The rest of that is all handled by Heroku. The DB_POOL may not be set, which will default it to 5 which is fine. You'll be able to easily change that as you scale up your Heroku servers.

Posted in Some good ways of seeding data in my app?

I'd probably toss everything in db/seeds.rb. Check out the ffaker gem for creating fake names and things.

If you need to create Devise users, you can just do this (but you'll have to give them passwords)

# You can optionally generate a password if you don't want to hardcode the password
# generated_password = Devise.friendly_token.first(8)

User.create(email: "test@example.com", password: "password", password_confirmation: "password")

And for paperclip images, you can use the ruby File library to open the file and assign it.

img = File.open(File.join(Rails.root, 'image.png'))
User.first.update(avatar: img)

You can use Rails.root there as a helper to get the Rails directory, and then you can join in any folders and filenames you need to get the full path in Ruby. Then you open it as a File object and assign that to your paperclip attribute. That should do the trick!

Posted in How to use devise with Adminitrate?

What is the contents of your app/models/admin.rb file? It sounds like the Admin class isn't defined in there for some reason.

Posted in How to use devise with Adminitrate?

Great question. If you want to use the existing Admin model from devise, all you need to do is add before_action :authenticate_user! to your admin controllers to force the admin user to be logged in. That should be it!

Posted in Sharing Data With Javascript Discussion

Wow, that's awesome, I'm really glad it was helpful! :)

You definitely don't need a frontend framework for this, so no worries there. :)

You're looking at some functionality that's sort of like infinite scroll on an index page, but slightly different because you're scrolling through the next and previous items individual. It's kinda like you're viewing the show action and then scrolling into the next show action.

The best solution here is probably something custom. Similar to how Ryan Bates in his revised Railscasts episode builds infinite scroll from scratch, but you'll need to add a "next" and "previous" method to the model in order to grab the next record for the show action instead of the next page of results that would be on the index.

Really I think with some minor tweaks, you could take the code from his episode to pull this off. You'd basically update the JS response to do the pushstate and append to the page, and set a link to the next episode that you can use for looking up the next result (instead of using will_paginate there).

I'd definitely like to do a screencast on this, because it's something you see popping up quite often.

Posted in CSV Import

You'll actually want to just make sure it matches the column name I think. You can print out the row hash to the console to see exactly what you'll need for that.

Yes that works! You should use your version, not the merge for this.

You can actually just add that into your query. For example, if your published column was a boolean: Post.search('*',where:{published:true})

Ah, the good ol' pebkac. ;)

It's interesting that even with the firewall, they seem to still be getting through. Maybe it's not working? I'm not well brushed up on firewall rules as I should be, but does UFW basically do the same thing as setting iptables rules?

Also you may want to make sure your log files are being rotated with logrotate so they never become unwieldy in size. Doesn't really solve your problem of constant attack, but does prevent your files from getting huge.

Posted in Get started with Rolify for roles

That's a great idea. This is definitely something that I've been wanting to cover for a while, so I'll make it happen!

Posted in Style a drop down menu with css

Hey JM,

I also added some code to remove that bell after you mark the messages as read. Once that AJAX call completes, the JS success callback just removes that div from the navigation. And that number is just the typical bootstrap CSS for the badge. You can inspect the HTML on the page to see what that looks like!

Posted in Sharing Data With Javascript Discussion

Check out the documentation here: https://github.com/rails/jb...

And my previous episode on fragment caching: https://gorails.com/episode...

Posted in Admin Interfaces with Administrate Discussion

Since these are just regular scaffolds, you can add routes and actions like you normally would. It's not really documented anywhere yet, but that's about all you would do.

Posted in Sharing Data With Javascript Discussion

No particular reason. I have been using CoffeeScript before ECMA 6 and am familiar with it so it's easy to use. Once nice thing is it's easily translatable to JS as well for anyone not familiar with it.

And yes, ECMA 6 (and 7) solve pretty much everything there. I'll have to do an episode showing how to use ECMA 6 with Rails as well.

Posted in Sharing Data With Javascript Discussion

Will do!