Thanks Ryan. I've been working on a some simple tagging with the native Postgres string-array type this week, it seems to work very well although I don't have any comparative data on performance yet.
Do we have XSS vulnerability because of displaying 'raw tags.map'? Hacker could inject some sort of malicious code in a tag name so it would be sent to user without escaping.
To completely get rid of the SQL queries issue, you can use staugaard's wonderful kasket gem (that Zendesk also uses, so, you know, probably okay for production :D)
If anybody else wants to use caching in their decorators / presenters and use HAML, then this is how to do it:
include Haml::Helpers
def haml_cache(key, &block)
self.init_haml_helpers
buffer = haml_buffer.buffer
h.with_output_buffer(buffer) do
h.cache key do
h.concat(yield)
end
end
Problem is, we need to have high throughput and are therefore using the nginx module to bypass Rails for uploading files and handle it directly via nginx.
It would be nice if anyone had a suggestion on how to combine the nice client side UI of jquery-file-upload and the backend of the nginx-upload-module ?
Hi, how can I create a new Comment inside my _form.html.erb of any model? I don't want to go to localhost:3000/products/1/tags to create a new tag, I would like to create it inside new.html.erb view of any model. I have problems with the line:
Has anyone gotten this to work with pg 8.4? 8.4 supports hstore but does not support the "CREATE EXTENSION" command. I am not sure what to use instead.
If you use Kaminari for pagination, there's no need for adding "click" event thru Javascript. Just adding :remote => true in the view works. Check https://github.com/amatsuda/kaminari
@pkohli1 - That's actually how it's supposed to work. Logging out on your app logs out the user from your system but that user should not be logged out of Facebook.
What is the best way of running a worker process on my vps? Is a detached screen session a good idea?
Should i add cron entry to lunch it on restart in case of a restart? Maybe there is a simpler way of doing it?
Is there a way to do this when you have nested forms (associations)? As in, we have a @license object, and every @license has @progress_point. Well, the form for licenses looks like this:
I have a Locations model with an belongs to association to my Areas model. The Areas model is setup with the Ancestry gem where I can build an arbitrary hierarchy of 'Areas' Say like this:
Main Area 1(id = 1)
- Sub Area 1.1 (id = 2)
-- Child Area 1.1.1 (id = 3)
-- Child Area 1.1.2 (id = 4)
- Sub Area 2 (id = 5)
-- Child Area 2.1 (id = 6)
-- etc...
So in my Locations model I have a area_id column and it's easy enough to call Locations.find(1).area.name = 'Child Area 1.1.2' and I can sort easy enough on this.
Now I have also created methods using ancestry functions in the Locations model to return the parent area's like this:
Locations.find(1).area_level_1 = 'Main Area 1'
Locations.find(1).area_level_2 = 'Sub Area 1.1'
Locations.find(1).area_level_3 = 'Child Area 1.1.2'
It's a bit of a hack but work except I can't sort on it. If I call Locations.all I can loop through and display a table etc. on a view and can create a sort function on the last child (i.e. area.name) but sorting based on area_level_1 fails. I am guessing there is an ugly manual SQL way to do this but I was hoping to perhaps find a more elegant way.
Where is really gets ugly is I am trying to leave the structure open enough where the area_id could only be 1 or 2 levels deep (i.e. id = 1 or id = 2 in my example data).
I use amCharts. It has some pretty advanced charting features for those needing them. It is a commercial product but well maintained and totally worth it. Available in Flash and Javascript versions.
Just a quick note if anyone else gets 'Dalli::RingError: No server available' (or it just says false when you try to write to the cache) I had run it as:
first of all, thanks... that's just what i've needed now.
But does anybody know why the video content is different from the Show Notes or even the Source Code?
That is because @products.class is Array, which responds_to? :to_csv. I guess you should call to_csv or whatever method name you have as class method: send_data Products.order(:name).to_csv
Sorry, the problem with the above solution is that both the parent and child processes will write out their pid to the worker's pid file. We just want the child so change it to:
ruby
after_fork do |server, worker|
ifProcess.ppid > 1# Not the daemon
child_pid = server.config[:pid].sub('.pid', ".#{worker.nr}.pid")
File.open(child_pid, "wb") {|f| f << Process.pid }
endend
Hi guys.
I tried sidekiq out for the first time. It is really cool. But I have a question. Which is the best way to starting sidekiq "bundle exec sidekiq" on server restart.
Found this episode really great, specially insight how properly do active record mixins. I'm already using arel specially when queries need some complex includes/joins and SQL doesn't look good in model.
I think Match method is overkill for this case, specially in high performance you would do raw queries for search + caching.
I've noticed that JQuery file upload supports chunking and resumable uploads. It's hard to find any info on how to do that in Rails. Any hints?
Is there any way to make simple_form work nice with ancestry?
I have alerts which have many categories, and categories are nested with ancestry.
Currently I'm using:
<%= f.association :category, :collection => Category.sort_by_ancestry(@organization.categories), :as => :check_boxes %>
But I would like to have categories nested visually.
Thanks Ryan. I've been working on a some simple tagging with the native Postgres string-array type this week, it seems to work very well although I don't have any comparative data on performance yet.
https://github.com/dockyard/postgres_ext was a huge help for getting started with it.
Do we have XSS vulnerability because of displaying 'raw tags.map'? Hacker could inject some sort of malicious code in a tag name so it would be sent to user without escaping.
Bitencode, I am SO glad I stopped by the comments section here after debugging for 3 hours :D thank you!
In the above code instead of changing window.location, is there a way to do this through ajax.
Doing this through ajax doesnt seem to work.
To completely get rid of the SQL queries issue, you can use staugaard's wonderful kasket gem (that Zendesk also uses, so, you know, probably okay for production :D)
https://github.com/staugaard/kasket
If anybody else wants to use caching in their decorators / presenters and use HAML, then this is how to do it:
end
That's a really great episode, thanks Ryan!
Although I am struggling to integrate this with nginx-upload-module.
( https://github.com/vkholodkov/nginx-upload-module/tree/2.2 )
Problem is, we need to have high throughput and are therefore using the nginx module to bypass Rails for uploading files and handle it directly via nginx.
It would be nice if anyone had a suggestion on how to combine the nice client side UI of jquery-file-upload and the backend of the nginx-upload-module ?
Any ideas?
Right. See also http://ubuntuforums.org/showthread.php?t=1889595 So, if you are on Ubuntu 12.04 or later, it better to use the 'sudo' group.
Thanks for the awesome video, Ryan. Just a note.
jQuery File Upload is great, however it does not handle any sort of file upload for IE since:
a) IE doesn't support drag and drop
b) IE doesn't support selecting multiple files.
In the situation of IE, you just fall back to single file uploads, while things like progress bars do still work.
Edit: Sorry, I should state it will upload multiple files for IE, but you still have to select them one at a time.
Adding the
ruby//= require private_pub
to application.js is missed in the manualHi, how can I create a new Comment inside my _form.html.erb of any model? I don't want to go to localhost:3000/products/1/tags to create a new tag, I would like to create it inside new.html.erb view of any model. I have problems with the line:
<% form_for [@commentable, @comment] do |f| %>
+1
Try Foreman (https://github.com/ddollar/foreman)
Has anyone gotten this to work with pg 8.4? 8.4 supports hstore but does not support the "CREATE EXTENSION" command. I am not sure what to use instead.
Great tutorial and great Gem!
I'm having an issue now that I'm trying to use this in production. in the private_pub.yml I have:
server: "http://mydomain.com:9292/faye"
and I keep getting "failed to load resource http://mydomain:9292/faye" in the javascript console and it doesn't work.
When I lose the port number in private_pub.yml I get a 406 error for faye.js
GET http://mydomain.com/faye.js 406 (Not Acceptable)
Any thoughts on what I'm doing wrong?
If you use Kaminari for pagination, there's no need for adding "click" event thru Javascript. Just adding :remote => true in the view works. Check https://github.com/amatsuda/kaminari
This one the other hand will work.
I am also running into the same problem - cropping works in Development but not in Production.
In Production, the resizable cropping box does not show up at all. I am running Rails 3.2.8.
@shallwelin do you mind telling me what you did exactly? did you have the same problem I do?
Thanks!
Google chart is also a good tool to display live data.
@pkohli1 - That's actually how it's supposed to work. Logging out on your app logs out the user from your system but that user should not be logged out of Facebook.
there are two GitHub projects which fork Resque and replace Redis with MongoDB:
https://github.com/streamio/mongo-resque
https://github.com/nfo/resque-mongo
This looks pretty awesome!
Not sure which one is more stable and/or feature-complete..
there are two GitHub projects which fork Resque and replace Redis with MongoDB:
https://github.com/streamio/mongo-resque
https://github.com/nfo/resque-mongo
This looks pretty awesome!
What is the best way of running a worker process on my vps? Is a detached screen session a good idea?
Should i add cron entry to lunch it on restart in case of a restart? Maybe there is a simpler way of doing it?
Very helpful, thanks!
If you want to use CSS triangles instead of images:
Do you mean like he does in #207? There is even a revised one.
Why memcached and not redis, for example?
me too
Is there a way to do this when you have nested forms (associations)? As in, we have a @license object, and every @license has @progress_point. Well, the form for licenses looks like this:
The partial "progress_point_fields" has:
The problem is that :progress_points isn't an @object so I can't exactly get the ID (or at least I'm not aware of any way of getting it).
Any ideas? Thanks in advance
I have a Locations model with an belongs to association to my Areas model. The Areas model is setup with the Ancestry gem where I can build an arbitrary hierarchy of 'Areas' Say like this:
So in my Locations model I have a area_id column and it's easy enough to call Locations.find(1).area.name = 'Child Area 1.1.2' and I can sort easy enough on this.
Now I have also created methods using ancestry functions in the Locations model to return the parent area's like this:
It's a bit of a hack but work except I can't sort on it. If I call Locations.all I can loop through and display a table etc. on a view and can create a sort function on the last child (i.e. area.name) but sorting based on area_level_1 fails. I am guessing there is an ugly manual SQL way to do this but I was hoping to perhaps find a more elegant way.
Where is really gets ugly is I am trying to leave the structure open enough where the area_id could only be 1 or 2 levels deep (i.e. id = 1 or id = 2 in my example data).
I am trying to implement the same thing. Here is my post on stackoverflow:
http://stackoverflow.com/questions/12496333/stange-behaviour-with-twitter-activerecord-reputation-system-average-rating
I tried to follow the same methodology as Ryan has here for the Haiku voting but I must be missing something on my structure.
The 'average' that I get back is not as expected and almost like the it's tracking the previous ratings.
Such a great episode!
Can you please guide me how I can go with cancellations, insufficient funds etc..??
Thanks in advanced.
I use amCharts. It has some pretty advanced charting features for those needing them. It is a commercial product but well maintained and totally worth it. Available in Flash and Javascript versions.
Just a quick note if anyone else gets 'Dalli::RingError: No server available' (or it just says false when you try to write to the cache) I had run it as:
memcached -l localhost
..and then it worked fine.
Great episode. One gold tip for me was localtunnel. Awesome and very handy!
Check out https://github.com/harvesthq/chosen/pull/166
first of all, thanks... that's just what i've needed now.
But does anybody know why the video content is different from the Show Notes or even the Source Code?
Edit: Sry, didn't see the Notes.
+1
Having difficulty creating delete and edit links for the polymorphic object.
Anyone know of a good resource on that?
Another useful gem for nested_form: https://github.com/ka8725/get_or_build
That is because
@products.class
isArray
, whichresponds_to? :to_csv
. I guess you should call to_csv or whatever method name you have as class method:send_data Products.order(:name).to_csv
You can also use g Raphael which is the library Raphael provides for drawing charts
Should
Time.zone.now
be in a lambda?Found nvd3 which seems pretty nice.
Quite interesting should also be Dimensional Charting Javascript Library.
Sorry, the problem with the above solution is that both the parent and child processes will write out their pid to the worker's pid file. We just want the child so change it to:
Add this to the bottom of your unicorn.rb
so that each unicorn worker creates its own PID. See this post for more info.
Hi guys.
I tried sidekiq out for the first time. It is really cool. But I have a question. Which is the best way to starting sidekiq "bundle exec sidekiq" on server restart.
Ryan, in rails master .rb was renamed to .ruby:
https://github.com/rails/rails/commit/de1060f4e02925c12004f2
Found this episode really great, specially insight how properly do active record mixins. I'm already using arel specially when queries need some complex includes/joins and SQL doesn't look good in model.
I think Match method is overkill for this case, specially in high performance you would do raw queries for search + caching.