When i add_fields. I want them to be associated to a class, "datepicker" Because when i click on a textfield that i render i want to display the datepicker. But it doesnt show up. It does when i have updated/saved the fields.
Ryan, did you know about the -c option when starting guard? It auto clears the screen using the clear shell command before each guard runs after detecting a change.
I worked through both screencasts and have a Rails 3 version working. It can be found here: git://github.com/johnzan/railscasts-episodes-episode-197.git
Great tutorial, I tried out this gem and quite suprised how easy it is. However I don't I will use it yet as will_paginate is having great meta_search integration that few of my projecst are heavily based.
Besides, will_paginate is going improvement to support rails3 simple scope style API, wait and see.
great post! small question though. but i'm wondering - how do i make faye server work automatically on production server ? right now i'm calling rack manually over ssh - there must be a better way :)
Hi,
I am going to implememnt this one for showing menus & sub menus,
but the problem is how to sort this one according user wish, like act_as_list it uses position to sort the list, is there any way I can sort the tress?
In nested_set it uses lft & rgt column, to sort entire tree..
Great Cast and Plugin! One little thing: I don't think the confirm password message is so useful. It should appear on the confirm field, not on the password field. But that's not really an issue with the gem but with rails.
Great ! I was playing with this gem since two weaks ago, trying to implement it in my project. However, my application raise`s an error that is making me mad: It`s raise an I18n::InvalidPluralizationData Exception. I`m using too delocalize gem, with helps me to translate my application to brazilian portuguese, and all my YML are working ok. Do you have any idea about this problem ? Thanks
Nice gem, nice presentation.
I would like to add a little suggestion. My watching experience would be even better if the lines in mate were wrapped, or broken up. As I often stop to read the code again - I am a fast learner if given plenty of time - I found it difficult to grasp the full context of the initializer file, line #9, stardate 2:10 to 2:20.
Thanks for the great work again.
Thanks for the RailsCast Ryan! I encourage people to check out the wiki as there are quite a bit of different ways to customize the behavior of the validations. (callbacks, filters, etc..)
I am using Kaminari to paginate the display of messages from a database of email messages. In my Show view for an individual message I want to add Next and Previous message links that navigate to the next and previous messages in the list of messages shown on the Kaminari-paginated page. I can't figure out how, from the Show view, to access the array of records that are displayed on a particular page. The message IDs are not necessarily consecutive.
The Search results are stored in @messages but I can't access that from the Show view.
How can I access the array of 25 messages for a page using params[:page]?
I just start working on a project that require some categorization. Should see this rails cast last night. The subtree and arrange are what exactly I'm looking for.
Cool gem and great cast. It would be also nice if ancestry provided with ~ #leaves method - set of children that have no children ... - quite useful in some situations ;)
This lib is amazing, thanks for this screencast. Note that #arrange method does not work perfectly if you have a too recent activerecord and an order clause in your default_scope's model. See the issue on github if needed ( https://github.com/stefankroes/ancestry/issues/42 ).
Ancestry uses the Materialized Path (MP) technique for encoding nested trees. It differs from Nested Set (NS) encoding in that with nested sets, each insert/update/delete updates close to half of the records in the tree. With MP, only the manipulated node and its descendants are modified.
This page [https://communities.bmc.com/communities/docs/DOC-9902] is a pretty good analysis of the three well-known nested tree encodings. Also, the book SQL for Smarties by Joe Celko treats this topic very nicely.
Thanks for this Railscast, I'll be needing nested tress very soon, and was not relishing writing my own implementation of MP.
How do you make a "select" input for let's say categories? They have an example https://github.com/stefankroes/ancestry/wiki/Creating-a-selectbox-for-a-form-using-ancestry ... but it doesn't really work as I did expect. It includes the current category you are editing... which is not cool. :-(
You really do have a uncanny way of covering the right topic just when someone needs it. I was wondering how to go about threaded comments areas, and frankly, not impressed with awesome_nested_set (and looked dated). Was going to just go ahead with a regular comments area for my project's launch, but Ancestry looks perfect and I think I will go ahead with threading. Thanks again.
Hey Ryan, just wondering why you use a `for message in @messages` loop in the messages index.html.erb rather than `@messages.each do |message|` block. Personal preference?
@Sairam, Ancestry has an ":orphan_strategy" option you can pass to determine how to handle the child records when the parent is deleted. Check out the readme for details.
@Aditya Them message content is already escaped when the message partial is rendered, so marking it as html_safe is fine here.
@Skully, yes, I did take a look at awesome_nested_set and the nested_set fork, but I liked Ancestry a bit more.
@jui, You can call the "depth" method on the model to determine the level and change the rendering accordingly. Alternatively if you can do this with CSS, change the styles depending on the ".nested_messages" depth.
This code is fantastic. Ryan, thanks for making a somewhat complicated concept appear so simple! I had spent half a day trying to get this to work another way, but railscasts came to the rescue!
Thanks, Ryan! I just finished building this identical functionality into one of my projects. Unfortunately, I'm still a beginner so I had to go the elementary route (essentially looping thru each parent comment and for each of them, looping thru the child comment). It works very nicely but I think I like your way of doing it better!
Thanks for this episode, Ryan. I`m about to build shopping cart, just for testing. For managing the categories i`ll use ancestry, but i have one question for you guys. How can i use different view for each level of the tree?
Perhaps in an advanced sequel to this, you can cover one of the jQuery plug-ins to create a file manager style functionality. I have one open source implementation which is non-ajax here:
http://www.github.com/bruparel/file_manager
Thanks for this episode, I will be sure to look into this.
I thought this was not covered, What would happen to the child messages when the parent message is deleted ?
Would this be controlled by the plugin that is being used to show ancestry list ?
Nice cast! If you're already fronting your webapp with Nginx I can also recommend the Nginx HTTP Push module which is very easy to setup and does pretty much the same thing in this example. Then you can setup locations in your Ngixx conf where you can long poll for messages on various channels and HTTP post to another location from your Rails app, which Nginx will forward to all active connections to the relevant channel.
Easy and very resource friendly on your web server machine.
You can have a public "pull" location but protect your "push" location in the conf so that posting messages need to go through your Rails app, but you can also have public locations for pushing where you wouldn't even need to hit your Rails app to create a shoutbox or something.
Hello, I notice the article id that you have in your video is 53582982. Is that the actual id of the article in the database or is it encrypted? If it's encrypted, did you use a gem for it?
Thanks for a great post!
I have a java-script related question, i think.
When i add_fields. I want them to be associated to a class, "datepicker" Because when i click on a textfield that i render i want to display the datepicker. But it doesnt show up. It does when i have updated/saved the fields.
Any ideas?
Thanks
/Filip
Nice RailsCast, as usual.
Ryan, did you know about the -c option when starting guard? It auto clears the screen using the clear shell command before each guard runs after detecting a change.
I was just this week looking for a solution to use with sprockets to automatically combine my javascript. Thanks for nudging me toward guard!
Awesome screencast. Thank you!
Ryan, how did you enabled colored output in guard (failure in red, passes in green); is that guard specific?
Thank you James!
I've been using your fantastic plug-in for about a year now. The pre-populate feature in particular is immensely helpful.
Kudos to Ryan for giving it the attention it deserves!
I worked through both screencasts and have a Rails 3 version working. It can be found here: git://github.com/johnzan/railscasts-episodes-episode-197.git
Hope this helps someone.
Great tutorial, I tried out this gem and quite suprised how easy it is. However I don't I will use it yet as will_paginate is having great meta_search integration that few of my projecst are heavily based.
Besides, will_paginate is going improvement to support rails3 simple scope style API, wait and see.
Great and thank you. I am trying to do some validation when exiting an input field. I changed one line in episode-136
In application.js line 9 change
this.submit(function() {
to:
this.blur(function() {
And get the following error:
Parameters: {"review"=>{"content"=>"some review"}}
ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.):
How can I get this to work with onBlur?
Oh, I would have posted to 136 but the signin using github did not work for me on that episode.
Thanks in advance!
great post! small question though. but i'm wondering - how do i make faye server work automatically on production server ? right now i'm calling rack manually over ssh - there must be a better way :)
Hi,
I am going to implememnt this one for showing menus & sub menus,
but the problem is how to sort this one according user wish, like act_as_list it uses position to sort the list, is there any way I can sort the tress?
In nested_set it uses lft & rgt column, to sort entire tree..
Is there any equivalent functionality available?
Please let me know.
Thanks,
Pradeep CS
Hey guys and Ryan, I added Mongomapper support to kaminari.. it's in the latest version :)
Iam using active record, and the validates_size_of, only checks the length of the name of the file, not the actual size.
How can I load the .irbrc file after the application gets initialized?
To: Abdul Shajin,
It worked for my rails 3 app.
Great Cast and Plugin! One little thing: I don't think the confirm password message is so useful. It should appear on the confirm field, not on the password field. But that's not really an issue with the gem but with rails.
I wrote a post how to add authors with ajax on /books/new:
http://slawosz.github.com/2011/04/26/add-new-resource-with-ajax/
It would be even better if the textboxes do not lose the focus if a validation is invalid - but nice screencast as always, Thanks.
I've been looking for an elegant way of doing this for a long while. Can't wait to checkout the code and take a look at how this is being implemented.
Nice screencast as always, looking forward to the redesign!
If I don't want to use AJAX, how can I remove the "utf=?" from the url? That's so annoying.
Thanks.
Another option is to use jCheck: http://jcheck.net, it also has the jcheck-rails that does automatic validation generation.
Great ! I was playing with this gem since two weaks ago, trying to implement it in my project. However, my application raise`s an error that is making me mad: It`s raise an I18n::InvalidPluralizationData Exception. I`m using too delocalize gem, with helps me to translate my application to brazilian portuguese, and all my YML are working ok. Do you have any idea about this problem ? Thanks
Good suggestion from iGEL (comment 13).
To have the page scroll to the top when the navigation link is clicked, simply append this line to pagination.js script:
$("html, body").animate({ scrollTop: 0 }, "slow");
In the screencast, you have *42* unread messages on github, Nice ! :)
Nice gem, nice presentation.
I would like to add a little suggestion. My watching experience would be even better if the lines in mate were wrapped, or broken up. As I often stop to read the code again - I am a fast learner if given plenty of time - I found it difficult to grasp the full context of the initializer file, line #9, stardate 2:10 to 2:20.
Thanks for the great work again.
Thanks for the RailsCast Ryan! I encourage people to check out the wiki as there are quite a bit of different ways to customize the behavior of the validations. (callbacks, filters, etc..)
I am using Kaminari to paginate the display of messages from a database of email messages. In my Show view for an individual message I want to add Next and Previous message links that navigate to the next and previous messages in the list of messages shown on the Kaminari-paginated page. I can't figure out how, from the Show view, to access the array of records that are displayed on a particular page. The message IDs are not necessarily consecutive.
The Search results are stored in @messages but I can't access that from the Show view.
How can I access the array of 25 messages for a page using params[:page]?
**Leigh
Thanks ryan,
I just start working on a project that require some categorization. Should see this rails cast last night. The subtree and arrange are what exactly I'm looking for.
I should use this insted of nested_set
Cool gem and great cast. It would be also nice if ancestry provided with ~ #leaves method - set of children that have no children ... - quite useful in some situations ;)
This lib is amazing, thanks for this screencast. Note that #arrange method does not work perfectly if you have a too recent activerecord and an order clause in your default_scope's model. See the issue on github if needed ( https://github.com/stefankroes/ancestry/issues/42 ).
Just a quick note --
Version 0.5.0 of Webkit has problems with both Webrick and Passenger ... after a pdf page is requested, all further requests come as PDFs too.
there's a fix here:
https://github.com/huerlisi/PDFKit.git
or version 0.4.6 seems to be working for others.
Ancestry uses the Materialized Path (MP) technique for encoding nested trees. It differs from Nested Set (NS) encoding in that with nested sets, each insert/update/delete updates close to half of the records in the tree. With MP, only the manipulated node and its descendants are modified.
This page [https://communities.bmc.com/communities/docs/DOC-9902] is a pretty good analysis of the three well-known nested tree encodings. Also, the book SQL for Smarties by Joe Celko treats this topic very nicely.
Thanks for this Railscast, I'll be needing nested tress very soon, and was not relishing writing my own implementation of MP.
@Alexander Try deleting the current category yourself in the controller.
Anybody who have suckerfish example from the ancestry`s wiki, working?
Although I ran rake jasmine, it doesnt seem to get my spec running. I named it piece_spec.js under the spec/javascripts/ folder... any clue?
I'm using rails 3.0.7 with Ruby 1.9.2
How do you make a "select" input for let's say categories? They have an example https://github.com/stefankroes/ancestry/wiki/Creating-a-selectbox-for-a-form-using-ancestry ... but it doesn't really work as I did expect. It includes the current category you are editing... which is not cool. :-(
Hice! Thx, but I have error "NoMethodError in ClientsController#update undefined method `eq' for nil:NilClass"
def update
@client = Client.find(params[:id])
respond_to do |format|
if @client.update_attributes(params[:client])
format.html { redirect_to(@client, :notice => 'Client was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @client.errors, :status => :unprocessable_entity }
end
end
end
Check this out: https://github.com/johnbintz/jasmine-headless-webkit
It's allows to run specs without hitting a browser. It's lightning fast.
You really do have a uncanny way of covering the right topic just when someone needs it. I was wondering how to go about threaded comments areas, and frankly, not impressed with awesome_nested_set (and looked dated). Was going to just go ahead with a regular comments area for my project's launch, but Ancestry looks perfect and I think I will go ahead with threading. Thanks again.
Hey Ryan, just wondering why you use a `for message in @messages` loop in the messages index.html.erb rather than `@messages.each do |message|` block. Personal preference?
@Sairam, Ancestry has an ":orphan_strategy" option you can pass to determine how to handle the child records when the parent is deleted. Check out the readme for details.
@Aditya Them message content is already escaped when the message partial is rendered, so marking it as html_safe is fine here.
@Skully, yes, I did take a look at awesome_nested_set and the nested_set fork, but I liked Ancestry a bit more.
@jui, You can call the "depth" method on the model to determine the level and change the rendering accordingly. Alternatively if you can do this with CSS, change the styles depending on the ".nested_messages" depth.
This code is fantastic. Ryan, thanks for making a somewhat complicated concept appear so simple! I had spent half a day trying to get this to work another way, but railscasts came to the rescue!
Thanks, Ryan! I just finished building this identical functionality into one of my projects. Unfortunately, I'm still a beginner so I had to go the elementary route (essentially looping thru each parent comment and for each of them, looping thru the child comment). It works very nicely but I think I like your way of doing it better!
*>Is that comparable with awesome_nested_set?*
awesome_nested_set has been superseded by
a fork which has been renamed to just "nested_set" https://github.com/skyeagle/nested_set
Thanks for this episode, Ryan. I`m about to build shopping cart, just for testing. For managing the categories i`ll use ancestry, but i have one question for you guys. How can i use different view for each level of the tree?
Is that comparable with awesome_nested_set?
Perhaps in an advanced sequel to this, you can cover one of the jQuery plug-ins to create a file manager style functionality. I have one open source implementation which is non-ajax here:
http://www.github.com/bruparel/file_manager
Thanks for this episode, I will be sure to look into this.
if the messages contain javascript, would that get executed now that we're using html_safe in the nested_messages helper?
I thought this was not covered, What would happen to the child messages when the parent message is deleted ?
Would this be controlled by the plugin that is being used to show ancestry list ?
Nice cast! If you're already fronting your webapp with Nginx I can also recommend the Nginx HTTP Push module which is very easy to setup and does pretty much the same thing in this example. Then you can setup locations in your Ngixx conf where you can long poll for messages on various channels and HTTP post to another location from your Rails app, which Nginx will forward to all active connections to the relevant channel.
Easy and very resource friendly on your web server machine.
You can have a public "pull" location but protect your "push" location in the conf so that posting messages need to go through your Rails app, but you can also have public locations for pushing where you wouldn't even need to hit your Rails app to create a shoutbox or something.
Hello, I notice the article id that you have in your video is 53582982. Is that the actual id of the article in the database or is it encrypted? If it's encrypted, did you use a gem for it?
Thanks,
Kyle H.