|
I think you're looking for something like https://github.com/norman/friendly_id Treehouse has a tutorial on how you can do it yourself http://blog.teamtreehouse.com/creating-vanity-urls-in-rails
|
# ? Apr 4, 2014 06:54 |
|
|
# ? Jun 5, 2024 03:25 |
|
Just use the friendly_id gem, it's quick and awesome.
|
# ? Apr 4, 2014 13:51 |
|
So a lot of you guys probably use apache or nginx on a relatively up-to-date distro. If you're using TLS as well, you better upgrade your packages, because a pretty big hole was found from openssl 1.0.1. http://www.openssl.org/news/secadv_20140407.txt Here's an online tool that you can use to see if you're vulnerable: http://filippo.io/Heartbleed/ Short checklist if you were affected (by no means comprehensive): - Update your system and make sure you're not vulnerable any more - Get new certificates - Regenerate a new Rails session secret to invalidate existing user sessions - Change any passwords or other potentially compromising information that might've passed through apache/nginx. On a side note, being still on RHEL 6 or Debian 6 mostly saved our asses at work. Smol fucked around with this message at 20:55 on Apr 8, 2014 |
# ? Apr 8, 2014 20:53 |
|
Smol posted:So a lot of you guys probably use apache or nginx on a relatively up-to-date distro. If you're using TLS as well, you better upgrade your packages, because a pretty big hole was found from openssl 1.0.1.
|
# ? Apr 8, 2014 20:58 |
|
Misogynist posted:Do note that RHEL 6.5 is vulnerable (though prior versions are not). That's true. Also certain extensions (like mod_spdy for apache) might include a newer, vulnerable version of openssl, making you vulnerable even if your distro still uses openssl 0.9.8. Smol fucked around with this message at 23:55 on Apr 8, 2014 |
# ? Apr 8, 2014 21:03 |
|
thanks for the heads up. most of my servers were vulnerable, especially since I had been using ubuntu 13.04 for dokku compatibility (docker had a bug in 13.10 that they just recently fixed).
|
# ? Apr 8, 2014 23:38 |
|
Rails 4/Mongoid 4 question: Is it possible to setup a scope which will query a referenced array of IDs, providing it either a singular ID OR an array of IDs, or will I need to make it into two scopes? Now that I've been away from my dev station for an hour, I'm thinking I can do it with one scope, and I was just passing the array improperly(would need to be a hash with the name of the referenced ID as the key for all of the values passed) For context, this is for filtering within calls to an API I'm building.
|
# ? Apr 10, 2014 01:57 |
|
Sitting Bull posted:Rails 4/Mongoid 4 question: If you're just trying to meet the requirement of "I can pass an individual ID, or an array of ids", .where supports that out of the box: code:
|
# ? Apr 10, 2014 02:09 |
|
enki42 posted:If you're just trying to meet the requirement of "I can pass an individual ID, or an array of ids", .where supports that out of the box: Thank you! This will do just fine. The whole thing was because I was building a query in the controller, and somebody said that I'd need to move it into a combination of scopes in the model to test it properly with RSpec, which this will satisfy.
|
# ? Apr 10, 2014 06:27 |
|
Weird Ruby 2.1 gets problem: I'm using zsh on Mac OS X, and gets doesn't recognize the return character. Whenever I run a script it enters the gets mode, I type in inputs, but whenever I press enter it just echoes ^M at me instead of returning from gets. Extra weird: running gets in the pry repl works just fine. Do I need to tell ruby how to handle Mac line endings?
|
# ? Apr 11, 2014 11:50 |
|
Sil posted:Weird Ruby 2.1 gets problem: I'm using zsh on Mac OS X, and gets doesn't recognize the return character. Whenever I run a script it enters the gets mode, I type in inputs, but whenever I press enter it just echoes ^M at me instead of returning from gets. Extra weird: running gets in the pry repl works just fine. Do I need to tell ruby how to handle Mac line endings? code:
Edit: Testing in a script: code:
code:
Jaded Burnout fucked around with this message at 15:02 on Apr 11, 2014 |
# ? Apr 11, 2014 14:57 |
|
Arachnamus posted:
Fixed itselfish. I updated zsh in a different terminal tab and then didn't restart the one I ended up using to run the script. Just tried the script now in a new terminal session and it works fine. Weird stuff. The old tab has a red X and a gear symbol at the start of the graphical prompt that should have clued me in that things were not kosher. Finally realized that I need to close the old terminal tab when I tried typing in a sudo password and enter didn't work there either.
|
# ? Apr 11, 2014 16:51 |
|
Didn't know FriendlyId was a thing that existed. Neat.
|
# ? Apr 13, 2014 13:42 |
Soooo is the Heroku sendgrid addon always going to get spam-filtered? Is there any way around this without going directly to sendgrid?
|
|
# ? Apr 14, 2014 21:11 |
|
I just added the addon and did `heroku addons:open sendgrid` and poked around their settings, and it looks like there are some DKIM options. I don't use them myself though so I'm not sure what to expect there.
|
# ? Apr 14, 2014 21:22 |
Mmm, I checked that out and it just rewrites the sender domain name. I think the issue is that Gmail thinks the IP range (heroku's?) for the sender is wack edit: Looks like Gold customers get their own dedicated IP? Sendgrid FAQ is saying there's a 'warming up' period for new IPs before ISPs have determined that you're worthy of not being flagged as spam A MIRACLE fucked around with this message at 22:20 on Apr 14, 2014 |
|
# ? Apr 14, 2014 21:41 |
|
A MIRACLE posted:Mmm, I checked that out and it just rewrites the sender domain name. I think the issue is that Gmail thinks the IP range (heroku's?) for the sender is wack I use Sendgrid free tier and none of my emails get marked as spam. This is small volume stuff to a set list of a few hundred recipients, though. After the first few thousand emails you should be fine. Make sure you are linking your domain to the emails and that your from/domain info match up.
|
# ? Apr 15, 2014 07:29 |
|
Sil posted:I use Sendgrid free tier and none of my emails get marked as spam. This is small volume stuff to a set list of a few hundred recipients, though. After the first few thousand emails you should be fine. Make sure you are linking your domain to the emails and that your from/domain info match up. Also set up SPF and DKIM. If you've set up SPF for Google apps or some other email provider, you also have to add an entry for SendGrid.
|
# ? Apr 15, 2014 16:28 |
|
Just checking to make sure I haven't missed something that's come out in the last few years, I want to be able to do something like:Ruby code:
|
# ? Apr 15, 2014 20:22 |
|
kayakyakr posted:Just checking to make sure I haven't missed something that's come out in the last few years, I want to be able to do something like: If you can turn a document into a single sort key, you can use Array#sort_by to sort on that key: http://rdoc.info/stdlib/core/Enumerable:sort_by The caveats about lexicographic sorting with strings vs. numeric sorting with numbers apply.
|
# ? Apr 15, 2014 22:47 |
|
Cocoa Crispies posted:If you can turn a document into a single sort key, you can use Array#sort_by to sort on that key: http://rdoc.info/stdlib/core/Enumerable:sort_by nope, can't be reduced in that way. Talked it over with Journey and it may need to be a gem, down the road, that gives a callback spot right before the values are returned.
|
# ? Apr 15, 2014 22:54 |
|
We have a WYSIWYG editor that we've built that splits content up into Rows and Pieces which are classified as RowTypes and PieceTypes. Basically it lets a user build a page by adding rows like "Two Columns of Text" or "An image with text wrapped around it" or "an embed code" or whatever, here I'll just post some screenshots so you can see what I mean: Okay so this, as you can imagine, is all done via associations, child relationships, nested attributes, and some considerable finagling of the excellent cocoon gem. It's all working fairly well and people seem to like it, but now we have a new requirement: we need to be able to safe draft versions, track some level of revision history, and allow reversions to previous versions of items that are built with this content (this editor is part of a larger CMS and it can be attached to any number of models). poo poo. I've looked into paper_trail and it doesn't look like it has a lot of support for saving a big cascade of nested models. I'm not against coding something up from scratch but I feel like someone must have solved this problem before. Does anyone have any suggestions for where to begin on something like this?
|
# ? Apr 16, 2014 03:24 |
|
prom candy posted:We have a WYSIWYG editor that we've built that splits content up into Rows and Pieces which are classified as RowTypes and PieceTypes. Basically it lets a user build a page by adding rows like "Two Columns of Text" or "An image with text wrapped around it" or "an embed code" or whatever, here I'll just post some screenshots so you can see what I mean: Welcome to my nightmares; I was the sole competent developer on a Rails CMS like this back in '08. The blasé answer is to polish up your resume. Review my assumptions: a Page is made of a bunch of Rows and Pieces, and a given row or piece belongs to one page and one page only. RowTypes and PieceTypes are shared between pages and don't really factor in to this discussion. You want to version a page, including its component rows and pieces. I'd probably look at denormalizing rows and pieces into a single field on a PageRevision, and keeping it either in a Postgres hstore or json column, or maybe a blob column.
|
# ? Apr 16, 2014 21:59 |
|
Tree structures, versioning & SQL. Sounds like you want closure tables if you want to keep it normalized. http://www.slideshare.net/billkarwin/models-for-hierarchical-data Smol fucked around with this message at 01:09 on Apr 17, 2014 |
# ? Apr 17, 2014 00:52 |
|
prom candy posted:We have a WYSIWYG editor that we've built that splits content up into Rows and Pieces which are classified as RowTypes and PieceTypes. Basically it lets a user build a page by adding rows like "Two Columns of Text" or "An image with text wrapped around it" or "an embed code" or whatever, here I'll just post some screenshots so you can see what I mean: Sounds pretty similar to something I had to build this year (various parent models have a series of various kinds of content chunks). Thankfully I don't forsee needing this level of revision history for our purposes but I'm interested to see what kinds of solutions exist.
|
# ? Apr 17, 2014 04:54 |
|
Has anyone had experience with CanCan? I have class_b which has a relationship to class_a. I want the load_and_authorize_resource call that cancan provides to authorize class_b's actions based on it's relationship to class_a. The documentation for cancan isn't clear about this, and I've tried the :parent and :through methods but it doesn't seem to be right.
|
# ? Apr 17, 2014 16:56 |
|
KoRMaK posted:Has anyone had experience with CanCan? I have class_b which has a relationship to class_a. I want the load_and_authorize_resource call that cancan provides to authorize class_b's actions based on it's relationship to class_a. The documentation for cancan isn't clear about this, and I've tried the :parent and :through methods but it doesn't seem to be right. 1) You should switch to CanCanCan as soon as you are able. CanCan has been abandoned by the creator and taken over by a group of others 2) I don't think you can rely on cancan's auto-load to do that. You might be able to build up a finder that can find the correct authorized classes and that would work. I would suggest going ahead and loading the resources in a before_action/filter, then calling authorize_resource (layer them in your class so you have: Ruby code:
|
# ? Apr 17, 2014 17:08 |
|
kayakyakr posted:1) You should switch to CanCanCan as soon as you are able. CanCan has been abandoned by the creator and taken over by a group of others poo poo, I had overridden find_resource instead. KoRMaK fucked around with this message at 18:46 on Apr 17, 2014 |
# ? Apr 17, 2014 17:11 |
|
Here's a more general question, how do I override a method that is used as a prepend_filter? Instead of doing before_action :load_resource, I'd rather just override the load_resource method from cancan https://github.com/ryanb/cancan/blob/master/lib/cancan/controller_resource.rb#L29 When I define the method in my controller, it doesn't ever get called. Why is that?
|
# ? Apr 17, 2014 18:46 |
|
Smol posted:Tree structures, versioning & SQL. Sounds like you want closure tables if you want to keep it normalized. Oh god I'm going to have to learn a whole bunch of stuff to do this right aren't I?
|
# ? Apr 17, 2014 20:40 |
|
prom candy posted:Oh god I'm going to have to learn a whole bunch of stuff to do this right aren't I? The classic book on the subject: http://www.cs.arizona.edu/~rts/tdbbook.pdf
|
# ? Apr 17, 2014 21:23 |
|
kayakyakr posted:1) You should switch to CanCanCan as soon as you are able. CanCan has been abandoned by the creator and taken over by a group of others I did the above, and it doesn't seem to work. Can you explain what the flow should be? Like, how do I get cancan to use the class_a that I loaded to do authing?
|
# ? Apr 17, 2014 21:27 |
|
KoRMaK posted:I did the above, and it doesn't seem to work. Can you explain what the flow should be? authorize_resource checks for an instance variable of the same name as the class. for MyClass it's looking for @my_class or @my_classes (on index) to authorize. You can override that with Ruby code:
As a reminder, cancan is not compatible with rails 4. most of it works, but some of it is very broken, especially when dealing with relations and how it does its lookups. CanCanCan rectifies some of that breakage.
|
# ? Apr 17, 2014 21:49 |
|
kayakyakr posted:authorize_resource checks for an instance variable of the same name as the class. for MyClass it's looking for @my_class or @my_classes (on index) to authorize.
|
# ? Apr 17, 2014 21:52 |
|
https://github.com/elabs/pundit is the new authorization kid on the block if you want to give it a shot.
|
# ? Apr 17, 2014 21:58 |
|
Oh My Science posted:https://github.com/elabs/pundit is the new authorization kid on the block if you want to give it a shot. This actually looks pretty fantastic- I might try to use it in some of my stuff at work.
|
# ? Apr 17, 2014 23:13 |
|
Wow, I just had a small error result in hours of confusion and lost work time. "Hash.key(:my_key)" is not the same as :Hash.key?(:my_key)" I knew this, I utilize both a bunch. I just overlooked the "?" It's kind of nice to feel so young and stupid again. (the load_resource solution kayakyakr suggested would have worked immediately if I hadn't made that mistake.)
|
# ? Apr 18, 2014 02:02 |
|
Smol posted:The classic book on the subject: Thanks! I've been trying to fill some of the gaps in my knowledge, database design is a huge one for me.
|
# ? Apr 18, 2014 04:43 |
|
I've been wrestling with Mercury Editor. Finally got it to work in my development environment, but when I pushed it to Heroku I ran into a problem that I struggled with all day today. I have the write-up here. Anyone have thoughts? The lovely thing is that Mercury's developer seems to have stopped working on it. Which is a shame, since it's pretty awesome. I haven't found anything that integrates so seamlessly with Rails.
|
# ? Apr 18, 2014 07:45 |
|
|
# ? Jun 5, 2024 03:25 |
|
We went through the exact same thing with Mercury editor. We gave up on it and switched to CK Editor using inline mode, and it has been great. Transition wasn't very difficult. We added an internal policy against using gems/libraries with less than 10 contributors on github because we've been burned a few times by solo projects like Mercury editor.
|
# ? Apr 18, 2014 08:34 |