Chris Oliver


255,520 Experience
22 Lessons Completed
281 Questions Solved


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:'*',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:

And my previous episode on fragment caching:

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!

Posted in Sharing Data With Javascript Discussion

Polling works just fine in a lot of cases unless there's an absolute _need_ to have realtime. It's rare for notifications to need to be truly instant. The other beauty of polling is that you can just write regular old Rails and JS code which you're already familiar with scaling. Probably 99% of the time, polling will do the trick just fine.

However, that's something we'll be talking about in the future. WebSockets are a whole lot more complicated to setup, manage, and maintain, so it will be a topic for a separate series (one that's coming soon!).

Posted in Sharing Data With Javascript Discussion

That's actually what I first did, but discovered that the way I showed in the video output and parsed the JSON just fine. I didn't run into any issues with it, but if it does become a problem for anyone, escape_javascript and some additional JSON parsing in the JS should do the trick.

Posted in Sharing Data With Javascript Discussion

It will add extra requests, but they are pretty simple, plus you can enable caching around the JSON response to make it fast.

Posted in CSV Import

  1. You'll probably need to modify that hash of attributes from the row. For example, you could transform it this way:
# Accept all fields you could ever want
attrs = row.to_hash.slice(:token, :order_id, :customer_id, :utm_campaign, :ordernumber, :customer)

# Set aliases
  token: attrs.delete(:utm_campaign),
  order_id: attrs.delete(:ordernumber),
  customer_id: attrs.delete(:customer)
  1. The col_sep option is what's used to define the column separators. You can add col_sep: ";" into your CSV parser section and that should do it. Some more info here on options:

Posted in Style a drop down menu with css

I was using Bootstrap to get the notification links in the header. No extra CSS needed for basic links like that.

Posted in Metaprogramming Virtual Attributes Discussion

Sweet! I figured there might be something to do that. I only ever clear the terminal in screencasts so I always forget to look that up. :)

Posted in Liking Posts Discussion

Glad you got it fixed! 👍

Posted in Using Pundit with ActiveAdmin

What a subtle bug, glad you caught that Dan. :) Should be fixed now.

I wonder if we can get a patch into ActiveAdmin that will correct that...

Posted in Use datatables like handsontable

This looks really cool! I'll definitely make an episode on this stuff in the near future.

In the meantime my recommendation would be to take a look at jbuilder. You can access the same routes as your forms do, but just do that in JS. Then you can and jbuilder responses like "show.json.jbuilder" right next to your show.html.erb file. That'll let you return a JSON object that your Javascript can use.

Same goes for submitting data to the server, you use the same URL as the create and update urls. Make sure the method is either a POST or UPDATE request if you're adding or updating data. The javascript library might expect certain formats for all the JSON you return, so that can help you design how to format your JSON responses for all these actions.

I don't know if that's enough detail to get you pointed in the right direction or not, but I hope that helps a little bit!

Posted in Using Pundit with ActiveAdmin

It's really unfortunate that's still happening. I don't know if this is relevant or not, but did you guys this?

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.