Chris Oliver

Joined

293,280 Experience
93 Lessons Completed
295 Questions Solved

Activity

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!

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
attrs.merge(
  token: attrs.delete(:utm_campaign),
  order_id: attrs.delete(:ordernumber),
  customer_id: attrs.delete(:customer)
)
order.assign_attributes(attrs)
  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: http://ruby-doc.org/stdlib-2.0.0/libdoc/csv/rdoc/CSV.html

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? https://github.com/activeadmin/activeadmin/issues/3068

Because you're using Ruby to inherit from User on both the TeamLeader and Agent, you're going to get access to everything already defined in User. It's kinda like how ever controller inherits ApplicationController. You get access to all the methods there.

If you don't want the admin? method to exist inside Agent, you'll want to move it out of User and put it in the TeamLeader class instead. Make sense?

Posted in Comments With Polymorphic Associations Discussion

You'll get there! I think you can add me as a collaborator to the private project temporarily if you wanted, but no worries if not.

I would also recommend playing a lot with plain Ruby because that will help wrap your head around all these things in Rails. It's mostly just regular old Ruby code just connected in various ways. The Ruby Pickaxe book and Metaprogramming Ruby are both really good.

Feel free to shoot me some emails as well! My email's on the about page I believe.

Posted in Comments With Polymorphic Associations Discussion

No, you'll still want that to reference the variable and not the class.

Do you have a github repo I can show you some fixes for this? It's kinda hard to give guidance in the comments. :)