I can remove / modify the question / answer stuff..
But when I add them, it will show the text boxes for the everything, but when I click submit, nothing is saved to the database. =/
I think it has something to do with :
def link_to_add_fields(name, f, association)
#create a new instance of the object, association
new_object = f.object.class.reflect_on_association(association).klass.new
print new_object
fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
#render the form partial
render(association.to_s.singularize + "_fields", :f => builder)
end
there are no errors. It just doesn't commit.
I noticed that your code also has jquery 1.3.2, So I added it to my project in the same spot (don't know if the program adds it automatically though... i haven't added it.. i tried... and nothing happened)
Regarding the Window's comment in the railscast. If you would like to manage multiple versions of ruby on windows please use pik which is an excellent windows tool by Gordon Thiesfeld. You can find it on Github at
Just installed RVM and it's great. Conveniently solved my problems following installing ruby 1.9.1 onto my development machine that hosts applications I am not ready yet to migrate.
I've set up RVM just last week because of the same reason you mentioned in your Railscast.
Congratulations for your 200th episode and thank you for all your hard work. I'll keep donating back to the open source community and am looking forward to see more Rails 3 magic in the upcoming episodes.
Congrats Ryan on 200 episodes! Most shows never hit 100… 200 is legendary!
It is Fantastic that a Rails 3 intro is episode 200! Any thoughts about the adoption of Ruby 1.9 or updating plugins/gems for Rails 3? It seems a little stagnant… why is that?
Hi, mobile devices often comes in different screen dimensions and capabilities, therefore you may need to render images that are optimized for a specific screen dimensions to maximize user experience. WURFL (http://wurfl.sourceforge.net/) is a powerful library that allows you to query and determined the characteristic of a mobile device from screen dimension to features and capabilities of mobile devices. The device list is update frequently from people around the world. There is a ruby version of it.
Is there a way to use this Mechanize to direct a user to their email provider and plug their username into the form and tab down to the password field? So essentially they signup and I redirect the to their email account where they just enter their password since I provided the username?
Works fine. My Problem: If I change from a textfield to a datetime select - which is what I need..on clicking the remove field it is disapearing from the view, but not deleting the date in the database.
Any idea? +thanks
Werner
"params" is a Hash (actually a subclass of Hash, HashWithIndifferentAccess), and its "keys" and "values" methods return arrays in no particular order. It's probably not a good idea to assume they'll pair up properly every time. Even if it works in practice, it probably exploits an undocumented fact about the Hash implementation.
Something like the following might be more bulletproof. It removes the assumptions but does basically the same thing:
Great Cast! If you are interested in building an actual iPhone App, I recommend ObjectiveResource which is an Objective-C port of Ruby on Rails' ActiveResource. check it out at http://iphoneonrails.com. I'm still looking for an Android library that does the same.
i played around with jqtouch and i was not impressed. iwebkit (http://iwebkit.net/) is much cleaner in all concerns: markup, capabilities, ui and documentation.
@myself (Comment #33) and everyone interested about the caching subject:
There is also the Vary header that can help to provide multiple content variants of the same resource URL.
See sections #14.44 & 13.6 of RFC 2616, or for the explanations about "Caching and Alternates" and the "Vary header" pp.401 to 403 of the "HTTP: the Definitive guide" (if you don't have this book, those pages are part of the preview available online at oreilly.com: http://oreilly.com/catalog/9781565925090/preview) Figure 17-2 illustrates the "Vary: User-Agent" mechanism.
The Vary: header method is Rails compatible out of the box (simply use "headers['Vary'] = 'User-Agent'" where needed), but it is not very efficient for the shared caches that sit between the clients and the server as they will have to keep one cache entry per existing User-Agent string...
If you're having trouble getting this to work with Rails 2.3, you might need to wrap the line in the development.rb like this: http://gist.github.com/294492
According my understanding of the RFC2616 (sections 14.14, 13.6 mostly), HTTP/1.1 allows you to serve multiple content variants of the same resource URL and have the cache layers working fine, thanks to the Content-Location and ETag headers.
Here's how I understood it works:
When serving a resource (let's say /resource/1) with a particular content variant, you specify this chosen variant's URL (/resource/1.html for "desktop" variant and /resource/1.mobile for the mobile one) with the Content-Location header and send the corresponding ETag.
When a cache layer is requested for that resource again, it will query the server with all the variants' ETag it knows (If-Match header) and, depending on whether one of the provided ETag corresponds to the actual resource variant to be served, the server sends a "304 Not Modified" answer with the corresponding Content-Location so the cache knows what content variant to send to the client.
However Rails does not seem to be currently ready for such behaviour (no signs of a Content-Location header in the sources for instance, except in the tmail library bundled with actionmailer) so yes, the best thing to do is to either use a subdomain and/or redirect the mobile and/or the desktop client to their corresponding variant (with a ".:format" extension,) thanks to the :format option of the url_for (and alike) helper methods.
I've just been having a play with PayPal and your RailsCasts are as usual extremely good and a massive help. Thankyou.
I would like to ask if it is feasable to use ActiveResource to communicate with sites like this? The new api's in PayPal X certainly seem quite happy to return nicely formatted XML.
If it is then it would be great to see a Railscast on this particularly as all the documentation deals with communicating with other Rails sites.
I can remove / modify the question / answer stuff..
But when I add them, it will show the text boxes for the everything, but when I click submit, nothing is saved to the database. =/
I think it has something to do with :
def link_to_add_fields(name, f, association)
#create a new instance of the object, association
new_object = f.object.class.reflect_on_association(association).klass.new
print new_object
fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
#render the form partial
render(association.to_s.singularize + "_fields", :f => builder)
end
link_to_function(name, h("add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")"))
end
there are no errors. It just doesn't commit.
I noticed that your code also has jquery 1.3.2, So I added it to my project in the same spot (don't know if the program adds it automatically though... i haven't added it.. i tried... and nothing happened)
any help you could provide would be awesome!
Congrats on episode 200, and know that your call to give back is going beyond rails as well :)
You've helped us all out.
What a coincidence !!! 200th episode comes out with rials 3. I always appreciate what you have given to the community.
Regarding the Window's comment in the railscast. If you would like to manage multiple versions of ruby on windows please use pik which is an excellent windows tool by Gordon Thiesfeld. You can find it on Github at
http://github.com/vertiginous/pik
~Wayne
Congrats on 200! I love your work, and look forward to new videos pop up in my reader.
Happy #200 episodes Ryan !
thanks for your amazing railscats, the best RoR resources ever !
Thanks Ryan,
congrats for 200
Just installed RVM and it's great. Conveniently solved my problems following installing ruby 1.9.1 onto my development machine that hosts applications I am not ready yet to migrate.
I've set up RVM just last week because of the same reason you mentioned in your Railscast.
Congratulations for your 200th episode and thank you for all your hard work. I'll keep donating back to the open source community and am looking forward to see more Rails 3 magic in the upcoming episodes.
Thanks,
Attila
Congrats Ryan on 200 episodes! Most shows never hit 100… 200 is legendary!
It is Fantastic that a Rails 3 intro is episode 200! Any thoughts about the adoption of Ruby 1.9 or updating plugins/gems for Rails 3? It seems a little stagnant… why is that?
I've been using RVM and I think it's a great idea to manage "Rubies" this way.
Thanks for the 'cast
Thanks Ryan and well done on reaching 200! You're making a huge contribution.
Congratulations on episode 200 :D I've learned allot through your episodes! :) Amazing work
Thanks Ryan, you are awesome!
Just amazing as usual
Congratulations for your AWESOME work along this 200 episodes. Thank you very much Ryan!!!
You can also segregate and use gems(ets) to install / manage your rails3 project, for example:
http://gist.github.com/296055
~Wayne
Congratulations Ryan! Thanks for providing such a great resource for us all.
Happy #200 screencast! Thank you so much Ryan! Your tutorials are the best! [And thank you to Asciicasts too!]
Congras #200! The best site about ROR!
Gongratz with your number 200 mate! Awesome!
Congratulations with #200 and thank you so much for all these wonderful explanations! Keep going, I love it!
As a note:
rails generate scaffold game name:string
can also be shortened by calling
rails g scaffold game name:string
Gratz on the 200th episode.
Did I mention I love this railscast?
Cheers on episode 200.
I think it would have been a scary coincidence if it were episode 300 ;-)
Keep them coming tho!!
Congratulations and thank you! That's all I've to say after 200 enlightening episodes.
Congrats Ryan on episode 200!
Keep up the good work.
congrats with your 200th!
Keep up the good work, cheers!
Nice thank you again :O)
Episode 200 and Rails 3 falling at the same time.. coincidence? I think not!
We've been waiting for this one. Thank you Ryan! P.S.: What a nice episode number ;)
I am running ruby 1.9 in xp and I cannot load the plugin it says
***** plugin not found
[git://github.com/thorny-sun/prawnto.git]
Please help
Hi, mobile devices often comes in different screen dimensions and capabilities, therefore you may need to render images that are optimized for a specific screen dimensions to maximize user experience. WURFL (http://wurfl.sourceforge.net/) is a powerful library that allows you to query and determined the characteristic of a mobile device from screen dimension to features and capabilities of mobile devices. The device list is update frequently from people around the world. There is a ruby version of it.
me again ;)
if someone got the 'add' part working with formtastic, please let me know...
Never mind, got one. Maybe someone can need id..
http://gist.github.com/297483
The JS won't work with formtastic because of the structure. Unfortunately, I haven't found a working equivalent.
(speaking of prototype)
Is there a way to use this Mechanize to direct a user to their email provider and plug their username into the form and tab down to the password field? So essentially they signup and I redirect the to their email account where they just enter their password since I provided the username?
Great as always.
I'd like to see more about jQTouch.
Thanks.
Works fine. My Problem: If I change from a textfield to a datetime select - which is what I need..on clicking the remove field it is disapearing from the view, but not deleting the date in the database.
Any idea? +thanks
Werner
Hmm, this line in the controller feels a little risky:
Product.update(params[:products].keys, params[:products].values)
"params" is a Hash (actually a subclass of Hash, HashWithIndifferentAccess), and its "keys" and "values" methods return arrays in no particular order. It's probably not a good idea to assume they'll pair up properly every time. Even if it works in practice, it probably exploits an undocumented fact about the Hash implementation.
Something like the following might be more bulletproof. It removes the assumptions but does basically the same thing:
keys = params[:products].keys
values = keys.map {|k| params[:products][k]}
Aside from that, thanks for all the helpful 'casts.
hi,I am very happy to have landed here.
Thanks for the great cast. This will really help.
I was impressed by how much jQTouch did. Have you heard of any prototype based libraries that perform similar tasks?
Thanks Ryan, this method just solve my idea of building mobile integration onto my project...
anyway, anyone still have the src for those old episode... especially on the sub domain episode...
Great Cast! If you are interested in building an actual iPhone App, I recommend ObjectiveResource which is an Objective-C port of Ruby on Rails' ActiveResource. check it out at http://iphoneonrails.com. I'm still looking for an Android library that does the same.
i played around with jqtouch and i was not impressed. iwebkit (http://iwebkit.net/) is much cleaner in all concerns: markup, capabilities, ui and documentation.
@myself (Comment #33) and everyone interested about the caching subject:
There is also the Vary header that can help to provide multiple content variants of the same resource URL.
See sections #14.44 & 13.6 of RFC 2616, or for the explanations about "Caching and Alternates" and the "Vary header" pp.401 to 403 of the "HTTP: the Definitive guide" (if you don't have this book, those pages are part of the preview available online at oreilly.com: http://oreilly.com/catalog/9781565925090/preview) Figure 17-2 illustrates the "Vary: User-Agent" mechanism.
The Vary: header method is Rails compatible out of the box (simply use "headers['Vary'] = 'User-Agent'" where needed), but it is not very efficient for the shared caches that sit between the clients and the server as they will have to keep one cache entry per existing User-Agent string...
If you're having trouble getting this to work with Rails 2.3, you might need to wrap the line in the development.rb like this: http://gist.github.com/294492
I found a solution:
prawnto :filename => 'filename.pdf'
Thx, Sandra
@Alex, @Ryan (Comments #19 & 20)
According my understanding of the RFC2616 (sections 14.14, 13.6 mostly), HTTP/1.1 allows you to serve multiple content variants of the same resource URL and have the cache layers working fine, thanks to the Content-Location and ETag headers.
Here's how I understood it works:
When serving a resource (let's say /resource/1) with a particular content variant, you specify this chosen variant's URL (/resource/1.html for "desktop" variant and /resource/1.mobile for the mobile one) with the Content-Location header and send the corresponding ETag.
When a cache layer is requested for that resource again, it will query the server with all the variants' ETag it knows (If-Match header) and, depending on whether one of the provided ETag corresponds to the actual resource variant to be served, the server sends a "304 Not Modified" answer with the corresponding Content-Location so the cache knows what content variant to send to the client.
However Rails does not seem to be currently ready for such behaviour (no signs of a Content-Location header in the sources for instance, except in the tmail library bundled with actionmailer) so yes, the best thing to do is to either use a subdomain and/or redirect the mobile and/or the desktop client to their corresponding variant (with a ".:format" extension,) thanks to the :format option of the url_for (and alike) helper methods.
I've just been having a play with PayPal and your RailsCasts are as usual extremely good and a massive help. Thankyou.
I would like to ask if it is feasable to use ActiveResource to communicate with sites like this? The new api's in PayPal X certainly seem quite happy to return nicely formatted XML.
If it is then it would be great to see a Railscast on this particularly as all the documentation deals with communicating with other Rails sites.