Ryan, At about 1:16 you say "brew install" and type "gem install" - just if some people are confused. What you type is obviously correct, not what you say :)
@Oktav, I'm planning on doing an episode on Resque some time in the future. Thanks for the suggestion.
@Nico, there is quite a bit of difference between Delayed Job and Beanstalkd and it's important to choose the right tool for the job.
Delayed Job is Rails specific and expects your Rails environment to be loaded for each worker. I prefer to keep the workers as light on memory as possible. CORRECTION: found out this isn't entirely true because it can be used in something like Sinatra with ActiveRecord or MongoMapper.
Delayed Job also polls for new jobs every 5 seconds by default. In this case I wanted it to respond as fast as possible with a new move and 5 seconds is quite a wait. It's also not an in-memory store so it's slower.
That said, Delayed Job is much more convenient and if it fits your requirements I definitely recommend it. It also has much better support for managing the jobs.
@Knodi, thanks for the warnings. In this case any pending moves or city names can be requeued so nothing is lost, however that is not the case for every scenario. I should have mentioned this in the episode.
Use beanstalkd with caution. Currently it lacks basic authentication and basic queue management (like pulling job state via job id). If there a queue problem you have to flush the whole queue bin. There is also lack of logging. So just be careful. That said its good but just know what your getting your self in to.
How to use render(association.to_s.singularize , :f => builder)
when the partial is
in a diffrent folder ?
in the view there are 3 folders: 'tests', 'questions', 'answers'.
so in '_form' in folder-'question' when there is a call to- link_to_add_fields("Add Answer", test_form, :answers)
i get the error-
missing partial 'tests/answer_fields'.
Hm, it seems to me more convenient to use Delayed Job for those kind of background tasks. Opinions? What would be the advantages of Beanstalkd over DJ?
Hi Ryan, you've done several episodes regarding background processing. Have you ever considered doing a cast about Resque. I've been using it for a while but the lack of extensive documentation leaves much space for experimenting.
Personally, I'd love to find out more. Thanks. Oktav
It relies heavily on touch because the pages I have a user acting on, are usually a collection of child records. Caching is a big help in this respect.Thanks
It's 2:41am in Brazil right now, it's raining cats and dogs outside, and I've got a project to deliver tomorrow. You just saved me. Thank you a lot, keep up the good work and may God bless you with more knowledge.
As said above, if you're getting a 401 error with Twitter authentication make sure of the following:
1) Registered Twitter app.
2) App should be set to "browser". If you leave the "call back url" field blank, it changes "browser" to "client app"
3) Call back url should be: http://127.0.0.1/auth/twitter/callback and NOT localhost/auth/twitter/callback
If you're using Rails 3 and have tried implementing the helper method in this screencast and it's throwing what seems like an endless loop and crashing your server, replace:
Total RoR newb here and I have to say this helped me a ton. I ended up moving over to awesome_nested_set for the reasons mentioned in previous comments. But there's a handy converter which makes it painless: Category.rebuild!
I have one doubt about the Question.rb example. If I use validates_presence_of :answers, and I send the form with _destroy = true, the nested model is destroyed without the validation
tells the form you are working on an object of type :child, and specifically the object @child, and the path to the child. In this case parent has_one :child, that's why its route looks the way it does.
I have migrated application rails 2.3.8 to rails 3.0.1 , in this while using paginate_all_by_receiver_deleted showing undefined method `paginate_all_by_receiver_deleted' for #<Class:0xb5ddb750>
Cash for inheritance is an option available to heirs who wish to sell inheritance assets bequeathed to them through a Will or trust. When assets are held in probate it can take several months or years before final distribution occurs. If heirs do not want to wait for estate settlement, they can assign inheritance rights to a funding source in exchange for a lump sum cash payment.
What would I do without Railscasts? Waste a bunch of time I suppose. Thanks again Ryan!! You do a great job of demonstrating how to program functionality that everyone needs.
I'm really loving thor. I made a gem to talk to Fusemail's API (email provider), and I wanted to build a CLI app so I didn't have to deal with their web interface. With thor I was able to throw together a compelte CLI app for every method with less code (~100 lines) than using optparser would have taken alone:
A n00b question: What's the difference between a method option and an argument? While watching this, I couldn't tell my you chose, for example, to make the "count" for the article-generation method an option rather than an argument. I'll watch again to see if it's clear…
I can authenticate against Google using OpenID but I do not get the access token, just the uid, so I cannot query any service to get data form Google. I need to get user's contacts
It is a very nice thing to see your excellent work and I like your article very much. With your rich knowledge, we can learn more from your wonderful post. Thanks so much.
Ryan, the omniauth railscasts are FANTASTIC. Many of us have been waiting for a multi-service authentication solution like this for some time, and the fact that you created 3 railscasts in order to give us some in-depth understanding of this powerful gem is totally justified and appreciated. Please keep up the excellent work!!
I have a strange behavior with the WHERE statement you use in your search method. It works fine on development using sqlite. But I am using Heroku for production, and "Foo" does not match anything when"Foo" is in the table, while "oo" does match "Foo" . Any idea ?
Thanks for the post.I really pleased to read it.I do agree that one can utilize a cookie to accrue the user name and the role, to evade to smack the users controller.
I consent with the above comments. In my views you can exploit a cookie to accumulate the user name and the role, to avoid to hit the users controller.
@Ahmed, that's just a bit of video editing so the viewers don't have to wait. The Rails environment takes a while on my end too.
@ARTSIOM, I haven't tried it yet, but I think setting the RAILS_ENV environment variable will work just like with Rake. You could turn this into its own command option in Thor to make it more convenient.
@Mark, cool, I didn't realize the "./" notation worked in require. Thanks.
@Carl, thanks for the suggestion. I hope to do more episodes on testing in the future.
I'd love to see some specifically on testing. That is definitely my weak point, but it feels like another system with it's own language to learn, even if you just go with the basic system. Anyone know some great screencasts for testing? I don't even know what framework to go with now.
Ryan, At about 1:16 you say "brew install" and type "gem install" - just if some people are confused. What you type is obviously correct, not what you say :)
Thanks for this, will spend some time learning.... This is the first I'd read about mechanize so looking forward to using it...
@Oktav, I'm planning on doing an episode on Resque some time in the future. Thanks for the suggestion.
@Nico, there is quite a bit of difference between Delayed Job and Beanstalkd and it's important to choose the right tool for the job.
Delayed Job is Rails specific and expects your Rails environment to be loaded for each worker. I prefer to keep the workers as light on memory as possible. CORRECTION: found out this isn't entirely true because it can be used in something like Sinatra with ActiveRecord or MongoMapper.
Delayed Job also polls for new jobs every 5 seconds by default. In this case I wanted it to respond as fast as possible with a new move and 5 seconds is quite a wait. It's also not an in-memory store so it's slower.
That said, Delayed Job is much more convenient and if it fits your requirements I definitely recommend it. It also has much better support for managing the jobs.
@Knodi, thanks for the warnings. In this case any pending moves or city names can be requeued so nothing is lost, however that is not the case for every scenario. I should have mentioned this in the episode.
Use beanstalkd with caution. Currently it lacks basic authentication and basic queue management (like pulling job state via job id). If there a queue problem you have to flush the whole queue bin. There is also lack of logging. So just be careful. That said its good but just know what your getting your self in to.
I suggest to recycle your rails server to reload the config initializer ... Thankx Ryan
How to use render(association.to_s.singularize , :f => builder)
when the partial is
in a diffrent folder ?
in the view there are 3 folders: 'tests', 'questions', 'answers'.
so in '_form' in folder-'question' when there is a call to- link_to_add_fields("Add Answer", test_form, :answers)
i get the error-
missing partial 'tests/answer_fields'.
it need to be:
- 'answers/answer_fields'
what i need to change?
thanks
Hi,
I see following strange error in my application
http://pastie.org/1351966
How to fix it?
Hm, it seems to me more convenient to use Delayed Job for those kind of background tasks. Opinions? What would be the advantages of Beanstalkd over DJ?
Hi Ryan, you've done several episodes regarding background processing. Have you ever considered doing a cast about Resque. I've been using it for a while but the lack of extensive documentation leaves much space for experimenting.
Personally, I'd love to find out more. Thanks. Oktav
Thank you.
I love mondays ;)
I was using magent for my mongoDB application. Will try out this for sure.
Thank You.
Excellent! Thank you!
It relies heavily on touch because the pages I have a user acting on, are usually a collection of child records. Caching is a big help in this respect.Thanks
It's 2:41am in Brazil right now, it's raining cats and dogs outside, and I've got a project to deliver tomorrow. You just saved me. Thank you a lot, keep up the good work and may God bless you with more knowledge.
As said above, if you're getting a 401 error with Twitter authentication make sure of the following:
1) Registered Twitter app.
2) App should be set to "browser". If you leave the "call back url" field blank, it changes "browser" to "client app"
3) Call back url should be: http://127.0.0.1/auth/twitter/callback and NOT localhost/auth/twitter/callback
Hope that helps.
so, is searchlogic working with Rails 3?
If you're using Rails 3 and have tried implementing the helper method in this screencast and it's throwing what seems like an endless loop and crashing your server, replace:
orders.where(:purchased_at => start_time.beginning_of_day..Time.zone.now.end_of_day).
in the helper with:
orders.where(:purchased_at => start_time.to_date..Date.today).
seemed to work for me.
Great helper method! It will be useful for me in the future. Thanks a lot!
to 58. zhubo : your comment is very important! It helps me fix my problem. Thanks a lot!
Total RoR newb here and I have to say this helped me a ton. I ended up moving over to awesome_nested_set for the reasons mentioned in previous comments. But there's a handy converter which makes it painless: Category.rebuild!
Thanks again, your site is awesome!
Thank you again for this railscast ;)
I have one doubt about the Question.rb example. If I use validates_presence_of :answers, and I send the form with _destroy = true, the nested model is destroyed without the validation
How can I fix this validation problem?
class Question < ActiveRecord::Base
belongs_to :survey
validates_presence_of :answers
has_many :answers, :dependent => :destroy
accepts_nested_attributes_for :answers, :reject_if => lambda { |a| a[:content].blank? }, :allow_destroy => true
end
@Kevin Whitaker
I had that problem and it was due to rails not being able to resolve my shorthand notation in the form_for statement:
BAD:
<% form_for([@parent, @child], :html => { :multipart => true }) do |f| %>
FIX:
<% form_for(:child, @child, :url => parent_child_path(@parent), :html => { :method => "put", :multipart => true }) do |f| %>
tells the form you are working on an object of type :child, and specifically the object @child, and the path to the child. In this case parent has_one :child, that's why its route looks the way it does.
Hi ,
I have migrated application rails 2.3.8 to rails 3.0.1 , in this while using paginate_all_by_receiver_deleted showing undefined method `paginate_all_by_receiver_deleted' for #<Class:0xb5ddb750>
any one faced this issue kind give comments
Cash for inheritance is an option available to heirs who wish to sell inheritance assets bequeathed to them through a Will or trust. When assets are held in probate it can take several months or years before final distribution occurs. If heirs do not want to wait for estate settlement, they can assign inheritance rights to a funding source in exchange for a lump sum cash payment.
I'm getting the following error when I attempt the reload command you used in your screencast, did bundler change?
<script src='http://pastie.org/1342982.js'></script>
Help me
/!\ FAILSAFE /!\ Thu Dec 02 14:02:38 -0500 2010
Status: 500 Internal Server Error
undefined method `match' for nil:NilClass
/usr/lib/ruby/gems/1.8/gems/pdfkit-0.4.6/lib/pdfkit/middleware.rb:12:in `call'
/sites/highliner.com/releases/20101202185932/vendor/rails/actionpack/lib/action_controller/string_coercion.rb:25:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/head.rb:9:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/methodoverride.rb:24:in `call'
/sites/highliner.com/releases/20101202185932/vendor/rails/actionpack/lib/action_controller/params_parser.rb:15:in `call'
/sites/highliner.com/releases/20101202185932/vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb:99:in `call'
/sites/highliner.com/releases/20101202185932/vendor/rails/actionpack/lib/action_controller/failsafe.rb:26:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call'
/sites/highliner.com/releases/20101202185932/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:106:in `call'
/sites/highliner.com/releases/20101202185932/config/initializers/mongrel.rb:62:in `dispatch_cgi'
/sites/highliner.com/releases/20101202185932/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:101:in `dispatch_cgi'
/sites/highliner.com/releases/20101202185932/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:27:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:159:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:282:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/usr/bin/mongrel_rails:19:in `load'
/usr/bin/mongrel_rails:19
Hi, as usual this is a nice article. I just follow him but I have a problem when I update entry without made any change. In log I can see:
ActiveRecord::ReadOnlyRecord (ActiveRecord::ReadOnlyRecord):
Does anyone has already seen this problem and known how to solve it please ?? I made a lot's of google search without try how fix it.
Thanks in advance.
when you got an error 'OAuth::Unauthorized', just restart your server.
What would I do without Railscasts? Waste a bunch of time I suppose. Thanks again Ryan!! You do a great job of demonstrating how to program functionality that everyone needs.
Does simple_form support text_field_tag?
I'm really loving thor. I made a gem to talk to Fusemail's API (email provider), and I wanted to build a CLI app so I didn't have to deal with their web interface. With thor I was able to throw together a compelte CLI app for every method with less code (~100 lines) than using optparser would have taken alone:
https://github.com/mudbugmedia/fusebox/blob/master/lib/fusebox/cli.rb
https://github.com/mudbugmedia/fusebox/tree/master/bin/fusebox
Much thanks to wycats! :)
A n00b question: What's the difference between a method option and an argument? While watching this, I couldn't tell my you chose, for example, to make the "count" for the article-generation method an option rather than an argument. I'll watch again to see if it's clear…
I can authenticate against Google using OpenID but I do not get the access token, just the uid, so I cannot query any service to get data form Google. I need to get user's contacts
@Ryan: you should really use Disqus or reCAPTCHA here
I enjoy using thor quite a bit. I wish thor would handle some of the simple things rake handles.
For example the file copy example. I like rake's file declaration syntax.
http://www.jbarnette.com/2009/08/27/on-rake.html
It is a very nice thing to see your excellent work and I like your article very much. With your rich knowledge, we can learn more from your wonderful post. Thanks so much.
Is it possible to use formtastic's semantic_form_for with a tableless model? Without using the Tableless gem?
Ryan, the omniauth railscasts are FANTASTIC. Many of us have been waiting for a multi-service authentication solution like this for some time, and the fact that you created 3 railscasts in order to give us some in-depth understanding of this powerful gem is totally justified and appreciated. Please keep up the excellent work!!
I have a strange behavior with the WHERE statement you use in your search method. It works fine on development using sqlite. But I am using Heroku for production, and "Foo" does not match anything when"Foo" is in the table, while "oo" does match "Foo" . Any idea ?
This one is enlightened blog post. Thanks a lot for sharing your valuable views through this blog.
ruby-debug interesting application!!i will try
Great episode as usual!
I would really be interrested in an episode about rails engine (with rails 3 ).
Looks pretty more integrated than in rails 2...
@Bharat
Just change line of code in the articles_controller in show action:
@commentable = @article
@comment = Comment.new
@comment = Comment.new
Thanks for the post.I really pleased to read it.I do agree that one can utilize a cookie to accrue the user name and the role, to evade to smack the users controller.
I consent with the above comments. In my views you can exploit a cookie to accumulate the user name and the role, to avoid to hit the users controller.
http://railscasts.com/episodes/200-rails-3-beta-and-rvm
@Ahmed, that's just a bit of video editing so the viewers don't have to wait. The Rails environment takes a while on my end too.
@ARTSIOM, I haven't tried it yet, but I think setting the RAILS_ENV environment variable will work just like with Rake. You could turn this into its own command option in Thor to make it more convenient.
@Mark, cool, I didn't realize the "./" notation worked in require. Thanks.
@Carl, thanks for the suggestion. I hope to do more episodes on testing in the future.
Seems interesting, I will keep in my bookmarks and try it when I will have some time.
I'd love to see some specifically on testing. That is definitely my weak point, but it feels like another system with it's own language to learn, even if you just go with the basic system. Anyone know some great screencasts for testing? I don't even know what framework to go with now.