Awesome screencast Ryan! I'm really glad you did this one now since I can see some great uses for app templates. I didn't have any problems with the video on Linux using mplayer.
I also experienced the movie getting cut off in the middle, at the height of the suspense. I was sooo engrossed. Ryan, Great movie. Please, can't we see the rest?
Just to save time for those of you who may have had the same idea that I did.
Idea:
Hey I could just use a virtual attribute to concatenate several fields and then use validates_uniqueness_of for an easy multiple field uniqueness check.
Answer:
Forget it, cannot be done, the validates_uniqueness_of method only works on actual database fields, no virtual attributes allowed.
Hello Ryan,
Ruby's output delimiter %q provides a concise alternative of here documents, especially when you have a few lines of code. You can see an example here:
I just have a question...I need to upload excel sheets and delete them once i save the data in them onto the database.
I am stuck at the deletion part of it.
This might just turn out to be insanely useful. The other day I started a fresh Rails app and realized just how many settings I were fiddling around with.. didn't feel very Rails like.
Scripts on Github, writing a function in the bash file.. great advice.
Sorted it (no pun intended, really). I had to do the for each on the association model in the middle. It looks like there are a few more db accesses to get anything from the models I really want though as each call to the associated model on the other side must get loaded afterwards.
All is working fine except for this line:
page.replace_html :notice, flash[:notice]
My flash messages are conditionally shown, as Ryan demonstrated in episode #18. Therefore, the RJS is crapping out because the "notice" element isn't available.
Simple problem, but looking to hear how you handled this.
Excellent, as always. I took your tutorial (from episode 40 as well) and made it more customizable. I wanted to share it with everyone (note this is not heavily tested!):
See my blog post:
http://railshacks.blogspot.com/2009/02/blocks-in-view.html
or dive straight into the code:
http://pastie.org/383089
@Mario, content_tag_for accepts a model as an argument, and it will give the tag attributes based on the model's name and id.
@pulkit, weird. Do you still have this problem? Perhaps GitHub was having difficulties.
@Jcooper, great question! If you just float the list elements to the left it should work. You'll also want to set the
":constraint => false" option on sortable_element so the item can be dragged horizontally as well.
@R Sturim, thanks, I'll definitely consider working on some more basic ajax screencasts in the near future.
@Shreyans, Rails is doing some magic here, it parses the name of the migration and knows we're trying to add the position column to the faqs table. This was added in Rails 2.0, see the episode on that for details.
http://railscasts.com/episodes/83-migrations-in-rails-2-0
@Ryan "But don't you need to use an after_filter instead of a before_filter so it resets at the end of the request instead of the beginning?"
Yes, must use a after_filter, that's exactly how I implement mine. Plus it keeps it from muddying up the controller.
I really love your screencasts and I will definitely donate some bucks to you :-)
One thing you could update is the source to the plugin. They are now on github and the maintainers strongly advise not to use the deprecated svn-repo :)
Ryan - i got that. if your controller was created using scaffold, by default your controller will have respond_to block... you need to add
format.rss { render :layout => false }
to that block.
Tutorials like these, the ones that focus on the "basics" are crucial to making our community standout from other web frameworks.
All average rails devs should be able to whip off a sortable draggable list in minutes. This screencast makes a nice dent in the right direction. I know there is voting out on UserVoice, but I would strongly encourage you to consider extending a few additional ajax centric screencasts similar to this to move our cumulative ball further down the field.
Perhaps centering on a few of the other scriptaculous modules such as expandable-collapsible divs, inline editing, ajax tabs, sliders, etc.
Essentially a toolbox of the common UI patterns we are commonly asked to provide our clients but are not always entirely obvious to implement.
But in my app, each user will have the power to sort the list in his own way.
I'm trying a "rich join table" with (user_id, item_id, position) to relate a item to a user and to know it's position in relation to this specific user.
But I keep getting errors. I know this insn't very clear... But if someone can help me how to do something like that, I would be thankful!
@Chess, in regards to deleting the folders, when I use 'has_many :photos, :dependent => :destroy' in my model that deletes the photos as well as the folders that contain them.
Thanks for the episode. I've learned a ton from you and am very thankful. If I can vote for a future episode topic, I'd like to see something about using an asset service like Amazon S3 with Rails. I have some upcoming projects that want to do heavy video streaming and have been thinking about using something like S3 for the application. Thanks!
Thanks for the example! I needed to do something like this today, and while I could have put it together myself from the pieces, your example is a complete picture of how I wanted to implement it, even down to the collection RESTful action :) And to think I stumbled across it through pure luck from Google, even before iTunes had downloaded today's video from the podcast.
i fix the issue with the return_url, to put the method on the side of paypal, just in the return_url add the field rm with value 2 and this will convert the form of return to the store xxxxx to method POST. if you put value 1 will be GET.
Ironically...the most valuable thing I got out of this was "each_by_index", haha! Found myself using a separate indexer "i" a number of times, had no idea this existed! Thanks Ryan.
If any of you out there are trying to use Ryan's technique to sort <tr> elements inside a table, make sure you
(1) read the documentation for Sortable.create, especially the important information under "Notes" (see http://wiki.github.com/madrobby/scriptaculous/sortable-create), and
(2) pass :tag => "tr" to your call to the sortable_element helper method.
Hi Ryan,
I am happy with your railscast video but i can't download source code.
When I tried to download source code of all episodes i got source code upto episode no.136 only.
Please check it out of there is any prob. in git.
As usual a great screen cast. If i wanted to create a new category and wanted to assign that category to the product, can you please do let me know how to do that?
How hard would it be to extend this to nested lists, using acts_as_tree? In particular, dragging a sublist item to another sublist, or making it a parent (out-denting)?
an idea for next weeks rails cast. expand upon this using categories. in an application i have now, i have my faqs linked to a specific category. my users can order the categories themselves in addition to the group of faqs under each category.
Don't forget to mention that the SQL indexes on the 'position' column MUST NOT be unique, because of the temporary duplicates created by the progressive updates in the sort action.
Awesome screencast Ryan! I'm really glad you did this one now since I can see some great uses for app templates. I didn't have any problems with the video on Linux using mplayer.
I also experienced the movie getting cut off in the middle, at the height of the suspense. I was sooo engrossed. Ryan, Great movie. Please, can't we see the rest?
Just to save time for those of you who may have had the same idea that I did.
Idea:
Hey I could just use a virtual attribute to concatenate several fields and then use validates_uniqueness_of for an easy multiple field uniqueness check.
Answer:
Forget it, cannot be done, the validates_uniqueness_of method only works on actual database fields, no virtual attributes allowed.
Michelangelo, you'd save another character if you dropped the "q" ;)
Heredocs can offer a different kind of concision, though: http://gist.github.com/60823
Hello Ryan,
Ruby's output delimiter %q provides a concise alternative of here documents, especially when you have a few lines of code. You can see an example here:
http://gist.github.com/60801
Thanks again!
For some reason, the MOV file stops halfway through for me. Anybody else have that problem?
Thanks for the great post!
I just have a question...I need to upload excel sheets and delete them once i save the data in them onto the database.
I am stuck at the deletion part of it.
I don't know, I just don't find this any more useful than keeping "templates" in Subversion (or git).
I have several project templates under version control and clone new projects off those.
I'm really impressed by the possibilities which these templates are providing to us.
I agree with Jamie, because customizing the app after running the rails command takes sometimes very long and could be now easily speedup.
great screencast!
Many thanks Ryan !!!!
This might just turn out to be insanely useful. The other day I started a fresh Rails app and realized just how many settings I were fiddling around with.. didn't feel very Rails like.
Scripts on Github, writing a function in the bash file.. great advice.
Sorted it (no pun intended, really). I had to do the for each on the association model in the middle. It looks like there are a few more db accesses to get anything from the models I really want though as each call to the associated model on the other side must get loaded afterwards.
I'm currently working through implementing this on a has_many through association. Are there any tricks involved in doing that?
Hey all.
Hoping for help with this.
All is working fine except for this line:
page.replace_html :notice, flash[:notice]
My flash messages are conditionally shown, as Ryan demonstrated in episode #18. Therefore, the RJS is crapping out because the "notice" element isn't available.
Simple problem, but looking to hear how you handled this.
Thanks.
Excellent, as always. I took your tutorial (from episode 40 as well) and made it more customizable. I wanted to share it with everyone (note this is not heavily tested!):
See my blog post:
http://railshacks.blogspot.com/2009/02/blocks-in-view.html
or dive straight into the code:
http://pastie.org/383089
Hi Ryan!
Nice cast as usual. Thanks!
But when I start to follow it I found that it could be done a little bit simpler.
What about set of methods like remote_form_for? (another really useful method is link_to_remote)
http://apidock.com/rails/ActionView/Helpers/PrototypeHelper/remote_form_for
jRails supports them as well. And you can keep application.js clear this way.
Another minor recommendation from jRails site regarding layouts/application.html.erb:
you can write just <%= javascript_include_tag :defaults %>
@Mario, content_tag_for accepts a model as an argument, and it will give the tag attributes based on the model's name and id.
@pulkit, weird. Do you still have this problem? Perhaps GitHub was having difficulties.
@Jcooper, great question! If you just float the list elements to the left it should work. You'll also want to set the
":constraint => false" option on sortable_element so the item can be dragged horizontally as well.
@R Sturim, thanks, I'll definitely consider working on some more basic ajax screencasts in the near future.
@Shreyans, Rails is doing some magic here, it parses the name of the migration and knows we're trying to add the position column to the faqs table. This was added in Rails 2.0, see the episode on that for details.
http://railscasts.com/episodes/83-migrations-in-rails-2-0
<% title t('welcome.title') %>
does this mean we can no longer do:
<%= title t('welcome.title') %>
I have tried it and it displays the entire :title in the browser.
@Ryan "But don't you need to use an after_filter instead of a before_filter so it resets at the end of the request instead of the beginning?"
Yes, must use a after_filter, that's exactly how I implement mine. Plus it keeps it from muddying up the controller.
Hi Ryan!
I really love your screencasts and I will definitely donate some bucks to you :-)
One thing you could update is the source to the plugin. They are now on github and the maintainers strongly advise not to use the deprecated svn-repo :)
URL:
http://github.com/mislav/will_paginate/tree/master
KR tschundeee
I am not sure how this will add position column to the faqs table.
script/generate migration add_position_to_faqs position:integer
Any idea on what's going on here?
For Rails people interested in commerce you should check out Spree which is an open source rails commerce platform. It uses ActiveMechant.
Ryan - i got that. if your controller was created using scaffold, by default your controller will have respond_to block... you need to add
format.rss { render :layout => false }
to that block.
Well that worked for me at least.
Tutorials like these, the ones that focus on the "basics" are crucial to making our community standout from other web frameworks.
All average rails devs should be able to whip off a sortable draggable list in minutes. This screencast makes a nice dent in the right direction. I know there is voting out on UserVoice, but I would strongly encourage you to consider extending a few additional ajax centric screencasts similar to this to move our cumulative ball further down the field.
Perhaps centering on a few of the other scriptaculous modules such as expandable-collapsible divs, inline editing, ajax tabs, sliders, etc.
Essentially a toolbox of the common UI patterns we are commonly asked to provide our clients but are not always entirely obvious to implement.
Kudos again,
-Rich
I cannot get this RSS feed to work either. I've had a look in IE7 and it displays a HTTP 406 "Internet Explorer cannot read this webpage format"
Any ideas?
Yeah! I made it!
Maybe it's not the best way to do that, but it's working.
If someone wants to know how I did it just reply here. For now I'll say sorry about the "flood" and thanks!
PS: Ryan, feel free to delete my 3 comments =)
Continuing:
To make it easier, I am logging successfully the data that I want:
item_id: 18, position: 1 and user_id: 1
item_id: 38, position: 2 and user_id: 1
item_id: 29, position: 3 and user_id: 1
item_id: 25, position: 4 and user_id: 1
item_id: 33, position: 5 and user_id: 1
I just need to save/update this in my database.
Ryan, I apologize about the semi-offtopic, but I don't know, maybe someone wants to do a personalized sortable lists too =D
Thanks, that's what I needed!
But in my app, each user will have the power to sort the list in his own way.
I'm trying a "rich join table" with (user_id, item_id, position) to relate a item to a user and to know it's position in relation to this specific user.
But I keep getting errors. I know this insn't very clear... But if someone can help me how to do something like that, I would be thankful!
I JUST finished figuring out this exact same thing, and then a railscasts comes along! Crazy
I browsed the comments, and don't think anyone has had a similar problem.
A record is created for the virtual attributes even when it's blank.
That is I have Profile.emails.build. I am not validating the presence of email, but I don't want a record to be created when no email is entered.
In this case, I get:
{"commit"=>"Create your profile",
"profile"=>{"new_email_attributes"=>[{"email"=>""}],
...
An object is created in the emails model.
In the case of your tutorial, it would be similar to an empty task object being created for the project model.
The only difference I can think of is my profile model belongs to the user model.
Anyone have any ideas why the email object is being created in my database?
Thanks.
Hello,
Great episodes on payment, they are very useful. I have just one question you may have address in other rails cast:
How do you do to have https form?
@Chess, in regards to deleting the folders, when I use 'has_many :photos, :dependent => :destroy' in my model that deletes the photos as well as the folders that contain them.
Thanks for the episode. I've learned a ton from you and am very thankful. If I can vote for a future episode topic, I'd like to see something about using an asset service like Amazon S3 with Rails. I have some upcoming projects that want to do heavy video streaming and have been thinking about using something like S3 for the application. Thanks!
I found a handy pdf to get you started with credit card processing:
http://jumpstartcc.com/
Most of the things were already mentiond by ryan, but its a nice overview.
Awesome as usual... Just wondering is this the same for organizing a gallery of images? If they are not just a list but in rows and columns?
I found that XPather is an excellent add-on for writing locators, especially when trying to write and debug tests.
https://addons.mozilla.org/en-US/firefox/addon/1192
Thanks for the example! I needed to do something like this today, and while I could have put it together myself from the pieces, your example is a complete picture of how I wanted to implement it, even down to the collection RESTful action :) And to think I stumbled across it through pure luck from Google, even before iTunes had downloaded today's video from the podcast.
i fix the issue with the return_url, to put the method on the side of paypal, just in the return_url add the field rm with value 2 and this will convert the form of return to the store xxxxx to method POST. if you put value 1 will be GET.
This is what I do with jQuery: http://henrik.nyh.se/2008/11/rails-jquery-sortables
It also uses a single query to update the index, which could be used just as well with Prototype.
Ironically...the most valuable thing I got out of this was "each_by_index", haha! Found myself using a separate indexer "i" a number of times, had no idea this existed! Thanks Ryan.
If any of you out there are trying to use Ryan's technique to sort <tr> elements inside a table, make sure you
(1) read the documentation for Sortable.create, especially the important information under "Notes" (see http://wiki.github.com/madrobby/scriptaculous/sortable-create), and
(2) pass :tag => "tr" to your call to the sortable_element helper method.
Hi Ryan,
I am happy with your railscast video but i can't download source code.
When I tried to download source code of all episodes i got source code upto episode no.136 only.
Please check it out of there is any prob. in git.
Cheers,
:)
Hello Ryan,
As usual a great screen cast. If i wanted to create a new category and wanted to assign that category to the product, can you please do let me know how to do that?
Thank you!
Pads
How hard would it be to extend this to nested lists, using acts_as_tree? In particular, dragging a sublist item to another sublist, or making it a parent (out-denting)?
an idea for next weeks rails cast. expand upon this using categories. in an application i have now, i have my faqs linked to a specific category. my users can order the categories themselves in addition to the group of faqs under each category.
Don't forget to mention that the SQL indexes on the 'position' column MUST NOT be unique, because of the temporary duplicates created by the progressive updates in the sort action.
What's the difference between content_tag and content_tag_for? I'm always using content_tag in my rails projects.
Andy,
Try this:
http://www.wil-linssen.com/extending-the-jquery-sortable-with-ajax-mysql/
How would you go about doing something similar with jQuery?
I mean, pure jQuery, without the jRails plugin...
Also very useful in this context (and a slightly different approach):
http://stackoverflow.com/questions/315850/rails-model-without-database