I have never seen an "up" (or "next") function that moves through the HTML DOM and return an element of a certain class. It sounds useful. Can someone post an online reference for this function?
If anyone is interested, I have a plugin called applicability that does something like this automatically. Mine, however, is for turning parts of a form on or off based on a select menu.
Hi Ryan, excellent tutorial series. I was looking for a simple way to do an admin kit while keeping the code DRY. This method seems right up my alley, especially since I'm very new to Ruby and Rails. Thanks!
Well, it seems that Rails2.0's restful controller.
I put some code to show like this,
-----------------------------
params(:result) do |status, identity_url, registration|
case status
when params(:result):missing
failed_login "Sorry, the OpenID server couldn't be found"
when :canceled
failed_login "OpenID verification was canceled"
when :failed
failed_login "Sorry, the OpenID verification failed"
when :successful
@current_user = User.find_by_identity_url(identity_url)
here in brazil, for example, we always use something like this with States and Cities, and we have over 5000 cities and 27 states. for this case, isn´t ajax the best solution ?? could u show us how??
hey, i guess it would be easier (less js), more responsive (no dom-(re)generation), more accessible (optgroups do logic grouping), cleaner (no global vars in js) to just group the options and show or hide the group-of-options according to the selected country...
<select>
<optgroup label="..." id="x">
<option></option>
</optgroup>
haha. I JUST implemented this a couple days ago (non-AJAX cascading selects). I'll have to revisit my code now that you've got this up. thanks for all the great screencasts
hey, u guys are doing a great job. i happened to come to ur site from www.techscreencast.com. They have a section full of videos on ror... some of the videos are from here... just wanted to say my thanks for ur efforts...
oops, I forgot to mention that I also had to put render :layout => false inside the dynamic_states controller so that I don't get all my html headers in what's supposed to be a javascript file
Very cool, I'm making a site right now and I was using rjs, but got stuck at the how do I observe at load (my js skills are very poor). Now I get the onload update and faster updates :D However I am doing this on Rails 1.2.3, so there are a few differences. I had to name my view dynamic_states.rhtml, but I still put the :controller/:aciton.:format route, and it works just fine. I also had to get prototype 1.6.0 because I was getting a javascript error that there was no document.observe function. I also recommend getting the latest scriptaculous because without it I was getting a javascript recursion error on another part of my site. Now I just cross my fingers and hope that the new javascript libs and old Rails play nice together for the duration of the site being built :D
Wow, some very great tips on using Javascript in Rails. How about an episode on the efficient use of Javascript e.g. compression or caching of large libraries such as prototype?
Thanks for this screencast - it has been really useful. One thing I don't understand is why you take the database.yml file out of version control. And what is the point of renaming it? Do I just upload this separately and then treat them as 2 separate entities?
What happens if you create more than one new task? i don't see how your code will work, the params parser is designed to ignore all same named parameters after the first rather than to collect them. That is how the checkbox hack works.
Is passing instance variables as arguments the only way to get instance variables into in the drawer method? I have a controller that collects/calculates a lot of information destined for output as rhtml or pdf.
Any tips or URLs I could follow would be appreciated.
@David: If you are having trouble seeing ALL the Railscasts, you can add the podcast manually from within iTunes. Just select "Subscribe to Podcast" from the Advanced menu within iTunes, then paste the full rss feed (feed://feeds.feedburner.com/railscasts) into the box. Once you click OK it should list ALL the railscasts.
(If not, try 'unsubscribing', deleting, and then follow the above instructions to 'reset' the list.)
Hi guys, this is a great tutorial! i have tried to get it to work with photos aswell but I can't seem to get it right. I am using a polymorphic photo table which may well be the problem. Does anyone have any suggestions on how i could get it to work?
I was having problems using will_paginate with scope_out. Another plugin "has_finder" seems to provide similar functionality only plays nicely with pagination:
Have you had any problems with bad characters getting into the RSS feed? Im curious if there'something already built to parse out these bad characters (like if someone copied and pasted text into the article content from a MS Word doc)?
Ryan, Thanks for the great screencasts they have helped me out tremendously. I really like your simplified tests. I'm new to the testing game (its never too late right?!) Any chance of seeing how you'd handle testing the other restful actions?
Great work! You have an incredible talent for teaching. I watch many screencasts but I can honestly say I don't anticipate watching any of them as much as yours. Thanks to you I even bought a 10-pack of peepcode screencasts which are quite good. But I still prefer your style and content. You seem to know exactly what to explain further as if you had JUST figured out how to do it and it was fresh in your mind and exciting.
Enough blabbering but thanks a lot for your commitment -- I am positive there are many out there like me who appreciate it.
@Mislav, I had completely forgotten about atom_feed_helper. That certainly would be a better solution. I'll link to it in the show notes. Thanks!
@Sam, I think you'll have to keep that respond_to block if you are specifying a custom layout. Alternatively you can rename the layout to "application" or the name of the controller so it will be picked up by default. That may not work in your situation though.
Great podcast. I have been following your podcast for a few weeks now and actually went back and watched all the previous ones. Great job!
I was able to implement the variable logging pretty easily. A couple quick random thoughts that are most likely stupid.
The idea is to quickly view variables but it would be really helpful if they were organized in someway. Maybe by data structure or if they are empty or not. This way a developer could get used to looking in the same place for nil values , hashes, arrays..etc. Dumb thought?
Hi Ryan. First of all, thanks for the excellent Railcast-episodes! They really help finding my way through.
I'm finding the title of this episode misleading, but maybe I don't understand things well enough just yet. Anyhow, imho we're not creating models but records, so I'd call the episode "Create record through text field".
cheers from the nitpicking-department
This is my first comment so I want to start by saying thanks for all the screencasts. They've been a huge help.
I'm in the process of implementing this and I was wondering what would happen if Akismet was offline. I disconnected from the intertubes in my dev environment and got a socket error crash so I'll need to catch that.
Also, I can't help noticing that a couple of helpless credit card user posts got through in December. I'm wondering if it would be worth running comments against Akismet more than once. Akismet's opinion of a comment might change after a day or two as it continues to learn. I'd just be concerned about abusing the TOS.
I was setting @page_title in my controllers until I saw this screencast... thanks, Ryan!
I like the idea of using content_for, but I'm not sure I can perform some logic on it like I can with an instance variable. I'm using the title method in application_helper.rb, only setting an instance variable instead of content_for.
In my application.html.erb, I do:
<title>
<% if @page_title.nil? -%>
example.com | an example site
<% else -%>
<%= @page_title %> | example.com
<% end -%>
</title>
What kind of javascript is this?
"up('.task')"
I have never seen an "up" (or "next") function that moves through the HTML DOM and return an element of a certain class. It sounds useful. Can someone post an online reference for this function?
If anyone is interested, I have a plugin called applicability that does something like this automatically. Mine, however, is for turning parts of a form on or off based on a select menu.
http://code.google.com/p/applicability/
Jon
I think rails filters confirmation field automatically if you filter the password field. So you don't need to explicitly say so.
Hi Ryan, excellent tutorial series. I was looking for a simple way to do an admin kit while keeping the code DRY. This method seems right up my alley, especially since I'm very new to Ruby and Rails. Thanks!
Well, it seems that Rails2.0's restful controller.
I put some code to show like this,
-----------------------------
params(:result) do |status, identity_url, registration|
case status
when params(:result):missing
failed_login "Sorry, the OpenID server couldn't be found"
when :canceled
failed_login "OpenID verification was canceled"
when :failed
failed_login "Sorry, the OpenID verification failed"
when :successful
@current_user = User.find_by_identity_url(identity_url)
great job/idea!!
here in brazil, for example, we always use something like this with States and Cities, and we have over 5000 cities and 27 states. for this case, isn´t ajax the best solution ?? could u show us how??
congratulations for this screencast!!
hey, i guess it would be easier (less js), more responsive (no dom-(re)generation), more accessible (optgroups do logic grouping), cleaner (no global vars in js) to just group the options and show or hide the group-of-options according to the selected country...
<select>
<optgroup label="..." id="x">
<option></option>
</optgroup>
<optgroup label="..." id="y">
<option></option>
</optgroup>
<optgroup label="..." id="z">
<option></option>
</optgroup>
</select>
... but as always... thank you for your efforts
Why can't I see the video on my iphone? I only hear the audio. I'm subscribed to the ipod version.
Anyhow, keep up the good work, nice podcasts! I wish I could watch them at the gym, though ;-)
@Phillip
I think that Array::transpose is what you want. That should just invert the matrix and you should be good to go.
--
Lou
Ryan - thanks a lot for doing this episode. It's been hard to find a solid tutorial on dynamic select menus.
haha. I JUST implemented this a couple days ago (non-AJAX cascading selects). I'll have to revisit my code now that you've got this up. thanks for all the great screencasts
hey, u guys are doing a great job. i happened to come to ur site from www.techscreencast.com. They have a section full of videos on ror... some of the videos are from here... just wanted to say my thanks for ur efforts...
oops, I forgot to mention that I also had to put render :layout => false inside the dynamic_states controller so that I don't get all my html headers in what's supposed to be a javascript file
Very cool, I'm making a site right now and I was using rjs, but got stuck at the how do I observe at load (my js skills are very poor). Now I get the onload update and faster updates :D However I am doing this on Rails 1.2.3, so there are a few differences. I had to name my view dynamic_states.rhtml, but I still put the :controller/:aciton.:format route, and it works just fine. I also had to get prototype 1.6.0 because I was getting a javascript error that there was no document.observe function. I also recommend getting the latest scriptaculous because without it I was getting a javascript recursion error on another part of my site. Now I just cross my fingers and hope that the new javascript libs and old Rails play nice together for the duration of the site being built :D
Railscast is like Knoppers, every morning at 9:30 in Poland :)
Wow, some very great tips on using Javascript in Rails. How about an episode on the efficient use of Javascript e.g. compression or caching of large libraries such as prototype?
Thanks!
Chris
I was just going to figure out how to do this today! Thanks for saving me time and effort once again!!
The <code>content_for(:head)</code> is very sweet!
hey! first comment comes from germany. great episode, ryan! every monday 9:00 in the morning, it's time to watch railscasts! philipp
Im getting this error:
Symbol as array index
on def task_attributes
why this ?
Hi Ryan,
Thanks for this screencast - it has been really useful. One thing I don't understand is why you take the database.yml file out of version control. And what is the point of renaming it? Do I just upload this separately and then treat them as 2 separate entities?
thanks,
DAZ
@Helena, you'll have to use a full find for that:
Task.find(:all, :conditions => ['name LIKE ?', name])
The shortcut find_by methods only work with equals comparison.
@Gernot Kogler:
What happens if you create more than one new task? i don't see how your code will work, the params parser is designed to ignore all same named parameters after the first rather than to collect them. That is how the checkbox hack works.
Thanks Bates.
It will be more convenience that have a link to the next episode in the page.
Thanks for the screencast.
Is passing instance variables as arguments the only way to get instance variables into in the drawer method? I have a controller that collects/calculates a lot of information destined for output as rhtml or pdf.
Any tips or URLs I could follow would be appreciated.
Thanks again.
@David, Yeah, I still need to fix the iPod feed. Thanks for reminding me. :)
@Sumit, I believe XMLBuilder automatically escapes the strange characters.
@Jai-Gouk, thanks alot for that information about the patch. /@
@All
I get the following error after returning to the website with OpenID authentication.
"Unknown action - No action responded to show"
Anyone got an idea?
@David: Oh, the iPod version works too. Just use
feed://feeds.feedburner.com/railscasts_ipod
for the feed address. :D
@David: If you are having trouble seeing ALL the Railscasts, you can add the podcast manually from within iTunes. Just select "Subscribe to Podcast" from the Advanced menu within iTunes, then paste the full rss feed (feed://feeds.feedburner.com/railscasts) into the box. Once you click OK it should list ALL the railscasts.
(If not, try 'unsubscribing', deleting, and then follow the above instructions to 'reset' the list.)
Hi guys, this is a great tutorial! i have tried to get it to work with photos aswell but I can't seem to get it right. I am using a polymorphic photo table which may well be the problem. Does anyone have any suggestions on how i could get it to work?
I was having problems using will_paginate with scope_out. Another plugin "has_finder" seems to provide similar functionality only plays nicely with pagination:
http://zargony.com/2007/10/20/paginating-special-queries-with-hasfinder-and-will_paginate/
Have you had any problems with bad characters getting into the RSS feed? Im curious if there'something already built to parse out these bad characters (like if someone copied and pasted text into the article content from a MS Word doc)?
what can I say, every cast is just great you really bring to light the features of rails I've been learning so much of the past months.
Keep them coming
And don't forget the auto_discovery_link_tag helper :)
Great episode, as always :)
http://api.rubyonrails.com/classes/ActionView/Helpers/AssetTagHelper.html#M001021
How can i get on itunes all episodes from railscasts ipod version ? I ask that because i can only download from 87 to 58.
Best regards!
Ryan, Thanks for the great screencasts they have helped me out tremendously. I really like your simplified tests. I'm new to the testing game (its never too late right?!) Any chance of seeing how you'd handle testing the other restful actions?
Great work! You have an incredible talent for teaching. I watch many screencasts but I can honestly say I don't anticipate watching any of them as much as yours. Thanks to you I even bought a 10-pack of peepcode screencasts which are quite good. But I still prefer your style and content. You seem to know exactly what to explain further as if you had JUST figured out how to do it and it was fresh in your mind and exciting.
Enough blabbering but thanks a lot for your commitment -- I am positive there are many out there like me who appreciate it.
Q: What did they call Ryan in Highschool?
A: Master Bates!
Kiddin! Your my hero, Ryan. <3 Keep it up.
Great stuff Ryan! Everyday I explore just a little more Rails 2.0 stuff. Keep up the good work.
@Mislav, I had completely forgotten about atom_feed_helper. That certainly would be a better solution. I'll link to it in the show notes. Thanks!
@Sam, I think you'll have to keep that respond_to block if you are specifying a custom layout. Alternatively you can rename the layout to "application" or the name of the controller so it will be picked up by default. That may not work in your situation though.
I found myself forced to use a respond_to cause I specify a layout for my controller
I have
layout "simple", :except => :index
and then
respond_to do |format|
format.html { render :layout => "simple"}
format.rss { render }
end
I hope I'm missing something ...
It's strange that you decided not to mention Atom and atom helper in Rails 2.0 at all
It worked for me....great episode as usual...keep up the excellent work
Hm the wget download works - it seems it is browser problem on my side.
I can't download the episodes :(
Great podcast. I have been following your podcast for a few weeks now and actually went back and watched all the previous ones. Great job!
I was able to implement the variable logging pretty easily. A couple quick random thoughts that are most likely stupid.
The idea is to quickly view variables but it would be really helpful if they were organized in someway. Maybe by data structure or if they are empty or not. This way a developer could get used to looking in the same place for nil values , hashes, arrays..etc. Dumb thought?
Hi Ryan. First of all, thanks for the excellent Railcast-episodes! They really help finding my way through.
I'm finding the title of this episode misleading, but maybe I don't understand things well enough just yet. Anyhow, imho we're not creating models but records, so I'd call the episode "Create record through text field".
cheers from the nitpicking-department
This is my first comment so I want to start by saying thanks for all the screencasts. They've been a huge help.
I'm in the process of implementing this and I was wondering what would happen if Akismet was offline. I disconnected from the intertubes in my dev environment and got a socket error crash so I'll need to catch that.
Also, I can't help noticing that a couple of helpless credit card user posts got through in December. I'm wondering if it would be worth running comments against Akismet more than once. Akismet's opinion of a comment might change after a day or two as it continues to learn. I'd just be concerned about abusing the TOS.
I was setting @page_title in my controllers until I saw this screencast... thanks, Ryan!
I like the idea of using content_for, but I'm not sure I can perform some logic on it like I can with an instance variable. I'm using the title method in application_helper.rb, only setting an instance variable instead of content_for.
In my application.html.erb, I do:
<title>
<% if @page_title.nil? -%>
example.com | an example site
<% else -%>
<%= @page_title %> | example.com
<% end -%>
</title>
Can the same effect be achieved with content_for?
I love these kinds of railscasts - being recipes instead of re-iterations of stuff you can find in the API etc. Keep 'em coming!