RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

THANK YOU!!! I needed this right now! I have been having so many problems with workling lately and it seems as though the developers have abandon support. I was working on a fix at this very moment and here it is! I love that this is the queue and worker all rolled into one!

Avatar

@Vlad, delayed_job is simpler than both Workling and BackgroundRb. It can also scale really well (it's used on GitHub). And overall it feels more stable.

Avatar

I cant download the screenshots. any advice reg that would be helpful

Avatar

Is there a way to display the comments on the page for each model (Article, Photo, Event)? Preferably, I'd like to create a universal partial for all the models to share, but I'm having trouble in doing so.

I keep getting the error "undefined method `comments_path' for #<ActionView::Base:0x38d3c24>" when I attempt to show the comment in the view for each model. Adding the comments resource back into the routes file allows me to view the comments as I would like to, but creating them redirects to /comments instead of /articles/1 like I would like it to.

Any help?

Avatar

I've been using workling, backgroundDRb, but delayed_job is much better, it just works without any problems

thanks

Avatar

Ryan,

Can you comment on why is DelayedJob better than BackgroundRb or Workling?

Here is a great resource on handling bg file upload on Amazon S3 with starling/workling: http://aaronvb.com/blog/2009/7/19/paperclip-amazon-s3-background-upload-using-starling-and-workling

Avatar

Awesometastic as always! :) Thx Ryan for your hard work!

Avatar

@Asfand, renaming it to content_for :script worked for me in 2.3.2. Example below.

in your layout:

<% content_for :script do %>
  <%= javascript_include_tag "nameofjsfile" %>
<% end %>

in your head: <%= yield :script %>

The place I needed it was actually in a partial that gets called inside a lightbox. It didn't work to have the code in the partial, so I had to add it into the page it was called from. I suspect that was a lightbox issue more than a partial issue.

Avatar

Thank you for the scast.

Setting "background: url(http://openid.net/images/login-bg.gif) no-repeat;" as a direct link on openid server may lead to overload. Think about using a local picture.

Avatar

Cron is not so hard to understand, but with such plug-in it became easier to use!

Avatar

Thanks again ryan. I took a Ruby on Rails class as part of my web design program at Vancouver Island University. Just wanted to let you know that I probably learned more from watching your rails casts than paying attention in class :P One of the classes I remember was to follow your railscast on restful authentication. Keep up the good work.

Avatar

I wonder how rails implement render action from views just like ASP.NET MVC?

Avatar

Thanks Ryan. Do you know how to implement excerpts with thinking sphinx?

Avatar

Ryan,

How about an episode that goes over a simple single sign-on system built in rails for multiple rails apps.

Thanks for all the great screencasts!

Avatar

Awesome tutorial as usual.

However, I can't get it to work with Yahoo, Google (and blogspot), etc.

It works with AOL (once I told it to export username/email). It works with myid.net. Etc.

But even though Yahoo and Google ask if I want to allow it (and I do), they won't return the nickname and email back so I am still getting a "Username/Email Required" error.

Any clues?

Thanks

Avatar

To those wanting "ajaxy" file uploads, look into the iframe remoting pattern. There are some articles on iframe remoting and attachment_fu that will work just as well for paperclip.

Avatar

Quick question: If the sweeper is observing the model (like an observer), why is a controller declaration required at all?

Avatar

Thanks Ryan for the railscast. I am a beginner to Webrat. I tried out the step you showed in it, but i am getting an error
undefined method `title' for #<ActionView::Base:0x49390c8>

Extracted source (around line #1):

1: <% title "Log in" %>
2:
3: <p>Don't have an account? <%= link_to "Sign up!", signup_path %></p>
4:

Please let me know where the issue is. I would greatly appreciate your help.

Avatar

Update for the instructions:

To get the latest version of starling you should use

gem install starling-starling

and not just "starling", or you'll end up with an old version.

Avatar

or for those who don't want to copy and paste: <a href="http://www.slideshare.net/mbleigh/twitter-on-rails-1396030">http://www.slideshare.net/mbleigh/twitter-on-rails-1396030</a>

Avatar

@arie until Ryan gets time, here's a slideshow: http://www.slideshare.net/mbleigh/twitter-on-rails-1396030

Avatar

BDD is fine. But it takes too much time when compared to TDD. Cucumber looks cool. But is there any real value of using it, when you are sure of the requirements? Because, it slows down the process so much.

Avatar

Thanks for the great video! One additional thing I had to do on my CentOS box to get this working was to specify the location of my Rakefile in the system call. I.e., I had to add:

system "/usr/bin/rake #{task} #{args.join(' ')} --trace --rakefile #{RAILS_ROOT}/Rakefile 2>&1 >> #{Rails.root}/log/rake.log &"

Avatar

If you need multiple photos for your object, I recommend this well written tutorial:

http://www.webyfi.com/?p=11

Read the comments as well, there are a few hints that might help you thru.

Avatar

hi Ryan,
plz have a look at plugin - http://github.com/kpumuk/meta-tags/tree/master, that uses idea from your railscast. Perfect thing :)

Avatar

Don`t understand what do this code

it "#{action} action should require admin" do
          get action, :id => 1

Avatar

So what is the user's URL, from outside of the application? Is it RESTful? Even though maybe form generated? (I don't read Ruby, sorry, I'm a PHP Head.)

Avatar

If you use one of the exception notification plugins mentioned in this episode, but want to receive SMS or phone call alerts instead of email, take a look at PagerDuty (pagerduty.com). It sends automated phone calls or SMS messages in response to any email based trigger. It also lets you route the alerts to different people depending on the day-of-the-week, etc.

Avatar

Great cast. Hints will definitely prove useful.

Avatar

Nice. Requesting railscasts on Facebook Connect and Sign in with Twitter.

Avatar

What about many-many polymorphic relationships?

If I have a Task model, and I want it to collect multiple Targets, how would I go:

task.targets
or
target.tasks

To me polymorphic relationships are a great way to approach mixed result sets without having to use STI.

I define an "abstract" model which defines the relationship to the polymorphic-collection. Then, every time I extend it, that class is eligible to participate in the polymorphic relationship.

Is there a way to do this without creating a two way dependency between the classes? Specifically, is there a way to do it without having to tell task about every target type it will ultimately collect?
I'd love to be doing this properly!

Avatar

I am not fully grasping what cucumber is doing behind the scenes here. While scenarios are being "passed" - all in green - nothing is being saved to the test database, correct? So how do we REALLY know they are passing?

Avatar

@Steffen

I wrote a blog post about paperclip and to_xml here:

http://www.mrkris.com/2009/06/18/paperclip-resized-image-details-in-to_xml/

Avatar

Ahh, i figured something important out, and this may help a few of you, many of the openid providers require you to explicitly choose to have openid make a username and email address available. By default most of them only return the a valid credentials response and the token.

For myopenid, got into your profile

Avatar

Hi Ryan,

Do you plan to cover ldap authentication through Authlogic too?

Avatar

OK, fixed - need to set config.action_controller.session in the environment.rb

Avatar

Love the article and try to do something similar but it doesn't work.

My database has a field called 'datum'. In my form I have a few groups of radiobuttons witch I gave the names 'datum_1', 'datum_2'... but they all have to post to the 'datum' field. So in my model I tried to change the names of 'datum_1', 'datum_2'... into 'datum' but it doesn't work. Can someone help me please?

Avatar

@pravin if your running ruby 1.8.7 you can get past the STARTTLS error put the line

:enable_starttls_auto => true,

in your ActionMailer::Base.smtp_settings hash.

Avatar

Very nice, Ryan. I recently started working on Skeletor, a skeletal Rails 2.3 app that uses Authlogic with OpenID and other common plugins/gems.

It's not polished yet, but I think it's a good start and I'm looking for feedback from the community.

http://github.com/jeremyw/skeletor/tree/master

Avatar

Follow-up: in map_openid_registration(registration) "registration" is an empty hash - so THAT's the problem. But why???

Avatar

I got it working 50% - but after returning from the OpenID provider I'm shown the registration form with two validation errors for login and email (too short) - they are empty. There is an OpenID URL for the user (https://me.yahoo.com/a/RXqidPob1_KpF0cfyeR.cycJcHax9.s). I cannot see anything wrong, views, models, controllers, are all simple enough after all... any ideas?

Avatar

@brett same here, I get:

undefined method `openid_identifier' for #<UserSession: no credentials provided>

Avatar

Also - how you manage to do this with only Saturday afternoons and Sundays not even that late into the night.. http://github.com/ryanb/railscasts-episodes/graphs/punch_card Maybe you could post an episode on how to balance the demands of life and code, cause you seem superorganized. http://github.com/chicagogrooves/chess_on_rails/graphs/punch_card bears so little resemblance to yours its hilarious :)

Avatar

Thank you Ryan, for another concise and very accurate one. I'm glad you did this the 'right' way through a join model. Self-referential made me think of this: http://pastie.org/546374, ugh !

This article was a better example of design than it was of 'railsy' stuff. Very hip and MDD ;)

Nice way to redeem yourself for the one where a rails controller spawns of a background process by appending an ampersand to a process name. You kick of processes per request, and you may as well be doing CGI. I know you may have a legitimate purpose and that you do not do this randomly. But also because it strikes me as a poorly documented dependency, one which even at runtime exists only ephemerally.

Anyway, nice one this time. Also, do you know of Dr. Nic - for some more design-level stuff you could show http://drnicwilliams.com/2006/10/04/i-love-map-by-pluralisation/ or metamagic models. I think his stuff is cool..

Ciao

Avatar

Hey Guys,
Don't panic if you are getting below error when you tried to run "cucumber features -n":

missing argument: -n (OptionParser::MissingArgument)

You are getting this error because cucumber version is now updated.

Try to run "cucumber features" and it will work fine!!!

Avatar

Looks good but what happen when your relation its has_and_belongs_to_many in one of the attributes ?

Avatar

Is the openid_identifier field also required on the UserSession table? I'm getting an error when I add the field to the login view.

http://gist.github.com/147267

Avatar

Another great thing would be to include how to test an openid login ( using cucumber for example )

Avatar

Yep, very good and very useful.

I second the request for some authorization casts!

Preferably using one of the frameworks like acl9 (which works quite nicely with authlogic)