@products is not the Products class object, but the method gets called. Then inside to_csv, it calls the all method. Does that repeat the query? or does it somehow apply all to the array @products?
To make it even more confusing, if I repeat this setup with an arbitrary method name instead of to_csv inside the rails console, I get NoMethodError. What's going on?
Rest is all similar as in the example but it isn't working for me. I went through the log. It didn't get any values in contact_ids. Where am I doing wrong. Need help.
I implemented this for a new API I'm building and my tests caught what I think might be a bug in the case where your default is an earlier version but you want to make later versions available. For example, you have v1, v2, and v3. v2 is still the default and you're testing v3. Because the matcher goes in order, when it hits the default (v2) it will match to that, even if you specified 'v3' in the Accepts header.
Here is how I solved it. I'm a bit of a n00b, so I'm sure you can make it prettier/more efficient.
Created an ACTIVE_API_VERSIONS constant so I know whether the version specified is active, in which case I can ignore the default.
ruby
ACTIVE_API_VERSIONS = ['v0', 'v1']
Modified the class like so
ruby
classApiConstraintsdefinitialize(options)
@version = options[:version]
@default = options[:default]
enddefmatches?(req)
if req.headers['Accept'] =~ /application\/vnd.example.v([0-9]+)/
ver = $1.to_i
ACTIVE_API_VERSIONS.include?("v#{ver}") ? @version == ver : @defaultelse@defaultend# @default || req.headers['Accept'].include?("application/vnd.linguixlabs.v#{@version}")endend
Yeah I understand, and I'm not knocking Sidekiq. I've been using sidekiq since it's early days, and in a very big project. It performs flawlessly. I was just expressing a sentiment that's all... I would rather just have one database to install/maintain/monitor. Kudos to you for creating and sharing sidekiq.
People have asked me to use ${FAVORITE_DATA_STORE} instead of Redis since day one of the project.
Sidekiq's mantra is simple and efficient. Having a storage layer with pg, redis, etc adapters and inherent performance trade-offs does not fit with those ideals.
Has anyone else had issues and found a resolution when using Outlook or any kind of multipart/HTML email and have it format nicely. How did you handle email signatures with images?
I have the same problem.
I don't know why "<% javascript "pagination" %>" is not work.
But
I fixed by: Add pagination javascript lib:
<%= javascript_include_tag 'pagination' %>
into EITHER header OR view
Reason: Without this javascript lib or this one was added before.
Using send_data method I can pass filename like that
format.csv { send_data @attendees.to_csv, {filename: filename}}
How can I change the default filename for xls without using send_date?
so my assumption was that the relation from authentication does not exist.
I added the following line in authentications controller
if authentication && authentication.user.present?
Not convinced about this project -- think it would be good for folks that have a lot experience with Threads and like this new nifty syntax. But i think it abstracts a lot of core concepts (Creating Threads, join(), Mutexs, blocking) that people new to concurrency should experience first hand before trying this.
I could not get this script to work (new to javascript). I am using model User instead of Person. I copied the script as it is on this page and changed all 'person' to 'user'. I put the script is users.js.coffee in my assets/javascript folder. It seems to ignore the script. When I select a state it shows all the countries and related states instead of only displaying the states for the selected country.
I have my fields in a partial that is used both in new and edit.
Again I am new to scripting. I believe that all I have to do is to add the script and it should work. I do this when I want to add functions using Bootstrap. Any help would be appreciated.
When you see any version of "$" it will refer to a global variable in Ruby. The global variable "$*" refers to the command line arguments passed into the program. (In this case the urls of the rss feeds.) It is not the same as simply declaring an array.
I did like you said but it raised another error so I decided to search for another tutorial. I've found http://notes.rehali.com/?p=97 very useful for me. Thanks for help.
Celluloid is really impressive (configurable concurrency solution) based on what i have seen so far.. a good option for ruby projects.. reducing or zero the learning curve or adoption of the likes of Scala (AKKA) or Erlang etc.. awesome.. soon, gone will be the days when ruby would be mocked for concurrency..
Great episode Ryan. The Devise Omniauth documentation isn't much detailed now and I was having trouble understanding the code samples.
In the episode, you mention that adding a separate Authentications model is 'a complexity that is not always needed'. If one requires to associate the user account with multiple providers, should we make a separate authentications model or add different keys to user model like twitter_uid, facebook_uid as Adam Sunderland mentions in an earlier comment?
The author wanted to give Ruby some of the features of Erlang. Check out the interview with him on The Changelog where he talks about Celluloid. The Changelog Episode .0.8.1. Great podcast!
Great episode, Ryan! It would be cool to see more on concurrency. :)
Great episode as always Ryan. +1 for a future episode that goes into setting up a separate model for managing identities (i.e. how to link multiple accounts to a local account and deal with the various edge cases). Keep up the great screencasts!
Thank so much Ryan for this and all other episodes!!!! I would like to see more about concurrency! Maybe differences between MRI and JRuby? Threads, forking and so on?
on the show page for route article/article_id, you coded a call to the comments controller index action to iterate through all the associated comments.
how do you code the show, edit, update actions in the article controller for individual line item comment manipulation?
Can anyone explain why the class method Products::to_csv is successfully getting called from the controller code below?
@products = Product.order(:name)
send_data @products.to_csv
@products is not the Products class object, but the method gets called. Then inside to_csv, it calls the all method. Does that repeat the query? or does it somehow apply all to the array @products?
To make it even more confusing, if I repeat this setup with an arbitrary method name instead of to_csv inside the rails console, I get NoMethodError. What's going on?
Will this work on Heroku? Does this mean I don't need all those Dynos?
I find my self combining this the OmniAuth part 1 lesson with this lesson in order to associate multiple accounts. It's located here: http://railscasts.com/episodes/235-omniauth-part-1?view=asciicast
I am trying to use this concept to delete multiple objects at a time. I added a button this way,
Rest is all similar as in the example but it isn't working for me. I went through the log. It didn't get any values in contact_ids. Where am I doing wrong. Need help.
I implemented this for a new API I'm building and my tests caught what I think might be a bug in the case where your default is an earlier version but you want to make later versions available. For example, you have v1, v2, and v3. v2 is still the default and you're testing v3. Because the matcher goes in order, when it hits the default (v2) it will match to that, even if you specified 'v3' in the Accepts header.
Here is how I solved it. I'm a bit of a n00b, so I'm sure you can make it prettier/more efficient.
Created an ACTIVE_API_VERSIONS constant so I know whether the version specified is active, in which case I can ignore the default.
Modified the class like so
true, good point. Thanks!
Yeah I understand, and I'm not knocking Sidekiq. I've been using sidekiq since it's early days, and in a very big project. It performs flawlessly. I was just expressing a sentiment that's all... I would rather just have one database to install/maintain/monitor. Kudos to you for creating and sharing sidekiq.
Could you poll Sidekiq to determine when the job finished and update the syntax highlighting with ajax?
Thanks so much, this just saved me after hours of struggling!
+1
Can you give a little more detail on this?
How can we use fragment caching w/ this?
Wow - supervisors. There's Erlang in my Ruby! I'd like to learn more about Celluloid.
Nice one! Thanks for doing this episode.
People have asked me to use ${FAVORITE_DATA_STORE} instead of Redis since day one of the project.
Sidekiq's mantra is simple and efficient. Having a storage layer with pg, redis, etc adapters and inherent performance trade-offs does not fit with those ideals.
Wouldn't that require that PG got push/pull support for its clients?
Nevermind, figured it out this morning.
+1
Has anyone else had issues and found a resolution when using Outlook or any kind of multipart/HTML email and have it format nicely. How did you handle email signatures with images?
thanks, I had the same question.
Great episode, was really useful, I published my first gem named Milo, it is a wrapper for the eBay Milo API. Thanks Ryan.
I have the same problem.
I don't know why "<% javascript "pagination" %>" is not work.
But
I fixed by: Add pagination javascript lib:
<%= javascript_include_tag 'pagination' %>
into EITHER header OR view
Reason: Without this javascript lib or this one was added before.
Using send_data method I can pass filename like that
format.csv { send_data @attendees.to_csv, {filename: filename}}
How can I change the default filename for xls without using send_date?
format.xls # { send_data @products.to_csv(col_sep: "\t") }
Very cool, but check out the license before using commercially.
nm, that doesn't work. I added an image to the summary but that doesn't seem to work either. Still looking for a solution.
Hi again,
so my assumption was that the relation from authentication does not exist.
I added the following line in authentications controller
if authentication && authentication.user.present?
which seems to solve the problem...
Not convinced about this project -- think it would be good for folks that have a lot experience with Threads and like this new nifty syntax. But i think it abstracts a lot of core concepts (Creating Threads, join(), Mutexs, blocking) that people new to concurrency should experience first hand before trying this.
I could not get this script to work (new to javascript). I am using model User instead of Person. I copied the script as it is on this page and changed all 'person' to 'user'. I put the script is users.js.coffee in my assets/javascript folder. It seems to ignore the script. When I select a state it shows all the countries and related states instead of only displaying the states for the selected country.
I have my fields in a partial that is used both in new and edit.
Again I am new to scripting. I believe that all I have to do is to add the script and it should work. I do this when I want to add functions using Bootstrap. Any help would be appreciated.
It is awesome, Ryan, I am impressed by celluloid.
All the shell scripts are using "$" as a reference to some vars.
When you see any version of "$" it will refer to a global variable in Ruby. The global variable "$*" refers to the command line arguments passed into the program. (In this case the urls of the rss feeds.) It is not the same as simply declaring an array.
Sidekiq runs as a separate process like Resque, Delayed Job, Qu, QueueClassic, etc. GirlFriday runs in the same process as your app server.
How this compared to GirlFriday? it uses the same concepts mainly
I did like you said but it raised another error so I decided to search for another tutorial. I've found http://notes.rehali.com/?p=97 very useful for me. Thanks for help.
Celluloid is really impressive (configurable concurrency solution) based on what i have seen so far.. a good option for ruby projects.. reducing or zero the learning curve or adoption of the likes of Scala (AKKA) or Erlang etc.. awesome.. soon, gone will be the days when ruby would be mocked for concurrency..
evented is not the same as threaded they have differente uses. Evented uses less resources too.
Great episode Ryan. The Devise Omniauth documentation isn't much detailed now and I was having trouble understanding the code samples.
In the episode, you mention that adding a separate Authentications model is 'a complexity that is not always needed'. If one requires to associate the user account with multiple providers, should we make a separate authentications model or add different keys to user model like twitter_uid, facebook_uid as Adam Sunderland mentions in an earlier comment?
I have added an interceptor (it sends email to the the admin) but then it stops sending the email to the user for some reason. I don't know why... I posted the question on Stackoverflow: http://stackoverflow.com/questions/11539690/rails-3-mailer-interceptor-conflicting
Very enlightening stuff on concurrency lately.
Will you cover some of the things that can be done for Rails? Like Rack::FiberPool?
This reminds me of Eventmachine. Would Celluloid be something that could replace Eventmachine in the future?
Programming with it seams a lot easier than EM.
The author wanted to give Ruby some of the features of Erlang. Check out the interview with him on The Changelog where he talks about Celluloid. The Changelog Episode .0.8.1. Great podcast!
Great episode, Ryan! It would be cool to see more on concurrency. :)
This was awesome celluloid reminds me alot of Erlang
Great episode as always Ryan. +1 for a future episode that goes into setting up a separate model for managing identities (i.e. how to link multiple accounts to a local account and deal with the various edge cases). Keep up the great screencasts!
Thank so much Ryan for this and all other episodes!!!! I would like to see more about concurrency! Maybe differences between MRI and JRuby? Threads, forking and so on?
I had never seen the $* for creating av array. What is the difference form using []?
Worth noting that celluloid only works on ruby 1.9
Would be nice if Sidekiq could use PG instead of Redis.
My head is spinning a little... thinking of all the things that could be done with this. Thanks - excellent episode.
on the show page for route article/article_id, you coded a call to the comments controller index action to iterate through all the associated comments.
how do you code the show, edit, update actions in the article controller for individual line item comment manipulation?
Thank you for this awesome episode.
This has really impressed me and I want to see more of this.