RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

@Daniel

http://github.com/yob/pdf-reader

and

http://github.com/sandal/pdf-inspector

@Powerplant,

We don't support PDF merging yet (and it's not planned for the near future), but you probably shell out to pdftk for that:

http://www.accesspdf.com/pdftk/

Avatar

Excellent screencast, thanks. Does anybody know how to merge PDF files in Prawn? I have created PDF (in Illustrator), which I want to use as cover for my generated PDFs. Thanks

Avatar

@Alexei
Was for me on 2.3.1.. hhmm wonder what the issue was then.

Avatar

Anyone know some good tool for read(parse) pdf files?

Thanks for another great video Ryan!

Avatar

Thanks a lot for making this Ryan. Hopefully we'll see lots of people joining up on the mailing list with any questions they might have:

http://groups.google.com/group/prawn-ruby

Avatar

@Mephux
Ryan told that it's not required.

Avatar

**NOTE:
You also will need format.pdf in the controller.. just thought I would add that.

Avatar

Thanks, Ryan

I've used it before and like it so far.
It's so good to see that you suggesting it too.
It mean that I've made good choice :)

Thanks and have a good week ahead!
;)

Avatar

@Millisami Are "XFA forms" the interactive forms that you sometimes see in PDFs?

If so, no. Prawn does not current support adding them to your PDFs. There was a discussion on forms on the prawn mailing list a couple of days ago though.

Avatar

Great screencast. This looks like a much cleaner/nicer way to generate pdfs, plus the tip about formatted path being taken out is helpful (I forgot about that myself).

Avatar

1)
I guess a nice use of default_scope would be while implementing "single table inheritance" structures.

I always had problems with the way rails handle it, but this way it is done behind the scenes. Perfect!

2)
In addition, I must say that I hated the way find_by_batches works. Splitting the badges according to a condition on id's is a bad idea. What if some records are deleted? Than batch sizes won't be predetermined. I would suggest the use of "LIMIT x, 10" syntax for a batch of size 10.
By the way this is true for MySQL, I don't know about the other DBMSs.

Avatar

I made it for the first time to be the first. Nice cast Ryan, helped me a lot. But does this work with the XFA forms??

Avatar

Important: named_scope currently doesn't merge :order options. Hence, neither does default_scope...

The result is that if you set default_scope :order => "name" you will not be able to order by anything else in another scope, even if you specify a different order explicitly:

Product.by_price
Product.this_month :order => 'price'
# still ordered by name!

The only way to change the order is by setting it in the final find call, not a scope:

Product.all :order => 'price'
Product.this_month.all :order => 'price'

Avatar

Ryan,

You are such a huge asset to the community. Thanks so much for all your hard work.

Avatar

@Hemant Just used that workaround for date_select. Works perfectly on 2.2.2.

Avatar

Is it possible to populate a field with a Float value?

Thanks for the great video and gem!

Avatar

Hi,

Thanks! for the screencast, it was very helpful.
 
Recently i came across the same issue with date_select and time_select that @Erik, @Tim and many others are facing.

Status: 500 Internal Server Error
Conflicting types for parameter containers. Expected an instance of Hash but found an instance of Array. This can be caused by colliding Array and Hash parameters like qs[]=value&qs[key]=value.

Here is the workaround for the issue:
http://agilerails.wordpress.com/2009/03/11/date_select-time_select-doesnt-work-with-auto_prefix-object/

Avatar

@Martin
I run into the same issue using rails 2.2.2

@PhilCK
Your solution worked for me as well

Avatar

@David, you may want to try integrating Facebook Connect comments. You can comment anonymously, if you do you have to pass a CAPTCHA. Or you can post a comment through your a Facebook login. It's very easy to integrate, free, and requires no knowledge other than copying and pasting. http://developers.facebook.com/ I love it and use it in every prototype I build.

Avatar

Hi Ryan,
I must say I really enjoy watching your screencasts and have benefited a lot from them, and I'd like to thank you for taking out time to do them. It can't be easy!

I have one request if you are able: would you be able to do a screencast on receiving email from a rails app?

Thanks and regards.
BTW What is the email that I can get to you on? [Please mail me] :)

Avatar

@egorbrandt It was probably being called from a partial as well? I had the same issue.

Avatar

Hi Ryan,

Whats the bet way to handle roles now wuld you use http://www.writertopia.com/developers/authorization ?

Avatar

If you can't nest the check boxes within your labels (for example, you need some special styling on the label), you can still link them easily using the dom_id helper.

Example based on the snippet at top of page:

http://gist.github.com/78264

Avatar

@andrej: You can use jQuery to highlight the search term in the results. Here is a nice example how to select the search term and wrap it into a styled span tag with jQuery:

http://www.ryancoughlin.com/2008/12/20/jquery-search-and-highlight/

Avatar

I'd be interested to know how one might allow a user to create multiple projects AND multiple tasks on one page with jscript. I couldn't find a rails only method for keeping each new project separate from one another. Right now I'm using a jscript iterator for each new project created that creates a new 'row' in a multi-dimensional array. Works but seems like a hack method. I'd much prefer a method that doesn't require javascript for separating new projects from each other.

Avatar

@Carl,

Thanks a lot. I'll look for it.

@Ryan,

I love your website design. Simple, pretty and effective. Thanks for all the greats screencasts. It's very useful for me.

Avatar

@Mark

I have just experienced a similar issue. I upgraded HAML and it fixed the problem. (2.0.9)

Avatar

@Allan,

I use mplayer to watch the screencasts on Ubuntu. You can find some info here http://www.medibuntu.org/ about codecs that are sometimes needed to play some videos on Linux.

Avatar

Thanks for a great series, again

Avatar

Thanks for the screencast Ryan.
+1 for globalize2 and Rails 2.3

Avatar

No one has mentioned performance... jquery is a lot more stable and faster in IE and FF. There are performance tests out there and you can see the difference is considerable and worth while if client side performance matters to you. Also the library size is smaller as well.

Avatar

How does this relate to the Rails 3 plan of putting rails apps inside rails apps?

Will 2.3 Engines be in someway compatible with Rails 3?

Avatar

Great screencasts.

How can I watch the video from Linux (Ubuntu) ?

Avatar

Ryan, great screencast! I really loved idea storing the search filters in database. What I am thinking is, if my model has really many fields (strings, integers, booleans) and I really want to provide a full advanced search to the user on every field, will I be then copying every field to the search model? Is there are way to reuse the fields but still keep the separate model?

Avatar

P.S. Nice overview, Ryan! These are the cream of the crop!

Avatar

@Roger, you should check out the named_scope Railscast in the show notes. It should answer your question nicely.

The scoped_by method is just a dynamic way to return scopes, whereas find_by and find_all_by query the database and cannot be scoped any further.

Avatar

Thanks for railscasts!! What is the difference between scoped_by and find_by?

Avatar

Safari can’t open the page “http://media.railscasts.com/videos/152_rails_2_3_extras.mov” because it can’t find the server “media.railscasts.com”

:(

I'm guessing there is just lots of traffic today

Avatar

Nice screencast. I'm on edge, but I did't realize that scoped_by_xxx was added (I still have to read the 2.3 release notes), it will clean once for all these one-purpose named scopes in model declaration.

One thing I noted while viewing your screencast is a important "detail" of the method .try I think you din't mention. .try changed from previous releases (I think it was already changed in RC1). Now only returns nil if you try(:something) over Nil, if you try(:something) over any other object, and :something it's not a method of that object, it will raise a NoMethodError. It's an important change to note, so it could lead to odd errors and to a misconception of the method purpose.

Thanks for all your awesome screencasts.

Cheers

Avatar

Seems getting this RC2 from the listed source is returning RC1 for me. Is there a cache (DNS or something) that needs clearing to enable this new version for install?

Avatar

I am waiting for nested models screencast too :)

Avatar

Great screencast as always !

Thanks Ryan !

I would like to see a screencast on i18n crud using globalize2 and Rails 2.3 nested form: is it possible ?

Avatar

Those are some great features. I read a discussion somewhere that if you are using MySQL there can be a performance problem with the way the find in batches works with really large datasets (hundreds of thousands plus).

Many of these are features I can really see some great uses for in my projects already.

Avatar

Very nice, I love the new 2.3 features

Avatar

Jimminy Cricket.

I figured it out (sort of). I've been pulling my hair out for days and just upgraded to rails 2.3.1 and the problem is gone. specify 2.3.0 in the environment.rb and it's back -- 2.3.1 gone.

So my logout with a mongrel cluster problem was not my problem at all.

Avatar

How do we add RESTful url to auto_discovery_tag? Any clues?

Avatar

Rajan,

You can watch live changes to your development.log file by doing "tail -f log/development.log"

Avatar

Thanks Ryan! Here's my notes for this screencast (also available at:
http://railsnotes.wordpress.com/2009/03/08/rails-rack-middleware-screencast-notes )

RailsCasts #151 Rack Middleware Notes

* Rack Middleware = filter which you can use to intercept a request and handle the behavior a little differently as it goes to and from the application

* Different between middleware & metal = Metal is an endpoint & middleware is designed to be more of a filter (changes behavior if it needs to.)

* Goes into /lib directory as a .rb file?

* All middleware takes a initialize(app) method. The app variable will hold the rails application

* Adding a call(env) method will make it override rails. This needs to return a array with the same 3 elements as a metal.

* to make rails use your middleware, add this to your environment.rb file inside the Initializer block: config.middleware.use "NameOfClass"

* 'rake middleware' will list out the middlewares used by your app

* You'll need to restart the server every time you create/change a middleware

* To execute your rails app from your middleware, just run .call on the rails app, ex: @app.call(env)

* you can assign parts of the response from a rails app to variables using something like this:
  status, headers, response = @app.call(env)
  
* and then you can call return those back to the real response using something like this:
  [status, headers, "Add stuff" + response.body]
  
* response.body assumes that the app is a rails app. this is not best practice.

* a better approach is to use [status, headers, self] together with def each(&block) `

Avatar

Here's the notes I took during this screencast:

RailsCasts Notes: #150 Rails Metal

* Bypass rails routing

* Simple request that happens frequently.

* to generate: ruby script/generate metal name_of_metal

* stored under app/metal/

* in the generated code, the self.call(env) method should return an array.
    1. response code ex. 404 or 200
    2. hash of header options
    3. Body content

* Won't be recorded in log file since it bypass that as well.

* When creating/changing a metal, you need to restart server (may change)

* If there is a conflict between Rails routing and metal, metal wins because it gets the request before rails has had a chance to process it.

* "ab -n 100 http://127.0.0.1:3000/processes/list" will run a benchmark that you can use to compare performance (just replace the url of page)

Originally at: http://railsnotes.wordpress.com/2009/03/08/rails-metal-screencast-by-railscasts/

Avatar

@Jonathan,

Did you ever get this working? I'm having the same problem.

I'm using Rails 2.3.0; and it all works fine when I run the app with mongrel, but as soon as I run it through a mongrel_cluster behind nginx I can login, but NOT logout.

Anyone else have any ideas why this might be?