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!).
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
- 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)
col_sepoption 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.
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.
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?
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.
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. :)
Well, that's a button_to, which is a POST, but update is actually an UPDATE request. You'd need to add the :method => :update to the button_to here.
Your destroy action should be put inside the regular CommentsController and should be in the same place as these. The only reason you need the nested routes and controllers is for helpers that make creating the comments (and referencing the original object you're commenting) on a little simpler. To destroy any comment, it doesn't matter what the original object was, you can just delete the comment itself if that makes sense.
I think you're passing in that variable into a partial actually(?), so that wouldn't actually solve your problem. You may need to make sure you're passing the right comment variable into your pundit stuff in each case.
You must link to the route that matches the destroy action. You're linking to a nested route, but you want to link to comments route directly.
Replace the polymorphic_path([commentable, comment]) in your button_to's to simply be comments_path(comment)
It sounds like you're passing in a variable that's nil then. Are you sure you're before_action :set_comment is being called?
Ah ha! So your errors is in the view, not your controller. :)
Change line 25 to say <% if policy(@comment).update? %>. Like I first guessed, you were referencing the class Comment, and not the individual record "@comment". That should do it!
That's exactly what I need. I might suggest removing the authorize @article in this function and keeping the one in your update action instead. Everything else looks right, so you might need to also send me the full error logs to see where exactly it broke.