Just running through the ascii cast and it seems that you are missing curl from this list of things that need to be installed before rbenv install will run:
But I'm not sure that you did correctly by moving price and released_at to product.js. It would be better if you made this methods in price.rb model and when you render product to json you would set methods price and released_at to render json format.
This is great, really great. When create an application with authentication, i used the
devise. But, after that i will try to integrate the warden. There is a very intresting
point that move our authentication up into Rack middleware. Great!
Every time our eyes keep on your screencasts.
Thank you Ryan,
Guys anyone knows how to apply this sortable logic for associations.
For example, i have a table videos (id, name, video_category_id) and video_categories (id, name). I am displaying video name and video category name in a table. Now when someone wants to sort using video category name, it should sort records with video category name instead of using video category id from the association column in video table.
I'm using rvm and have managed to deploy 1 app with a certain degree of success. I'm now struggling to deploy another where my gems are defined in a gemset. Unicorn seems to be expecting them in the global space. Any idea what I can stuff in my unicorn.rb to tell it to use my gemset in this instance?
Hey Ryan, great cast as usual. Karol's question above is still open, my Google searches thus far have not turned up any answer. Besides making a plugin, is there a place Rails 3 looks for custom generators outside of a Rails app as it did in Rails 2?
In your 'how I test' presentation, you use factory_girl_rails and guard-respec. Where do they belong in this setup? The Gemfile refers to the gemspec file, so should they go in the gem spec file? And can you use instructions like ,
I had all sorts of trouble getting the cropper changes to work. Firstly, you'll need to restart your Rails server every time you change the Paperclip changes.
Secondly, I couldn't really get the cropping code to work without putting quotes around the resize and cropping amounts. Because I always crop to a certain size, I completely replaced the array used in the transformation command.
ruby
modulePaperclipclassCropper < Thumbnaildeftransformation_commandif@attachment.instance.cropping?
crop_command
elsesuperendenddefcrop_command
target = @attachment.instance
if target.cropping?
sTransform = "#{target.crop_w.to_i}x#{target.crop_h.to_i}+#{target.crop_x.to_i}+#{target.crop_y.to_i}"
sTransform = ('"'+sTransform+'"')
trans = []
trans = trans << "-crop" << sTransform
trans << "-resize" << "\"800x200\""
trans
endendendend
Apologies for the Hungarian notation. Old programmer & bad habits die hard.
This is almost eerie. I was just now Googling around for an in-place edit solution in Rails... and suddenly it shows up as one of the latest Railscasts :). Awesome!
FYI - Devise no longer uses GET for the sign_out it uses DELETE. So you need to make your log out button/link use the DELETE method. Or change your route so to something like this which will use GET.
devise_scope :user do
get "/logout" => "devise/sessions#destroy"
end
Slightly OT question. Where did you get this comprehensive list of states/countries? I know many sources but they all require fair amount of work to import in rails db.
Wow, coming up to 3 years old and this is still a super easy way of doing sorting by dragging. I have just used this approach alongside your brilliant nested attributes tutorials (http://railscasts.com/episodes/196-nested-model-form-part-1) and it works just as well as the simple model example you use in this tutorial.
For me I have a Page model with nested attributes on a Snippet model (all very CMS based). If anyone was thinking of doing the same, go for it. I did this - it may help you:
1 - added a controller for the nested model - "Snippet" in my case (not needed otherwise) which just contains the "sort" method as you have it i.e.
ruby
classSnippetsController < ApplicationControllerdefsort
params[:snippets].each_with_index do |id, index|
Snippet.update_all(["position=?", index+1], ["id=?", id])
end
render :nothing => trueendend
2 - add the drag n drop code to my show view rather than my index view like this:
erb
<ul id="snippets">
<% for snippet in @page.snippets %>
<%= content_tag_for :li, snippet do %>
<span class="handle">[drag]</span>
<%= snippet.body %>
<% end %>
<% end %>
</ul>
<%= sortable_element("snippets", :url => sort_snippets_path, :handle => "handle") %>
it helped me to keep the sorting feature out of the way of the nested attribute feature in the edit view for my parent model
3 - since i am Rails 3.0.x based i have added a default_order scope to my nested model to handle the sorting bit:
ruby
classSnippet < ActiveRecord::Base
belongs_to :page
acts_as_list
scope :default_order, order("position")
end
4 - for Rails 3 i have also used the routing approach added by Tyler Gannon in these comments i.e.
ruby
resources :snippetsdo
collection do
post :sortendend
all works a treat. thank you for your excellent work as always Ryan!
glenn
p.s. the great thing about all this is that it just works without messing about! i was especially happy that the sort method only acts on those "id's" that i am currently working within my "show" view and NOT all objects i.e. it updates the positions for those snippets in my current page, not all snippets. the acts_as_list gem is optional for me in that my position attribute is optional but i may also end up with several snippets with NO positions by default so i'd sooner have positions added by the acts_as_list gem on new snippets - even if the calculated 'next position' is not scoped to my current page model. it's no big deal because as soon as you reorder your snippets it all sorts itself out!
Just running through the ascii cast and it seems that you are missing curl from this list of things that need to be installed before rbenv install will run:
sudo apt-get install build-essential zlib1g-dev git-core sqlite3 libsqlite3-dev curl
Added a link to the 'cast to the project README. Thanks, Ryan!
In that case, see: http://railscasts.com/episodes/283-authentication-with-sorcery
Worth to mention that I had to add the 'type' options to make capybara work properly.
tags: paths NoMethodError undefined method 'visit'
Devise uses Warden under the hood.
Fantastic! This could very much come in handy for future projects.
Thanks!
It's just great!
By the way, I think there is a typo error on the Show Notes > Resources
Divise Warden Strategies (devise?)
Tnx. That was very useful. I'm currently rewriting the authentication of production app and both of today's episodes have been exactly what I needed.
You can also pass other options such as form in the initializer to override the login form. Like this:
Thanks for doing this Ryan. Again, you have read my mind by creating this. Also, thanks to Intridea for kicking ass!
i think rails should have an authentication and permission engine by default. Anyway sorcery authentication looks much more clean to me.
Thanks Ryan for wonderful episode!
But I'm not sure that you did correctly by moving
price
andreleased_at
to product.js. It would be better if you made this methods in price.rb model and when you render product to json you would set methodsprice
andreleased_at
to render json format.explicitly rendering the collection partial,
instead of the shortcut
render @search.products
sorts the problem
You can't really remove the default OmniAuth identity pages because they are part of the omniauth-identity gem. You just stop using them.
Ryan,
Great screencast!
One thing though.. you did not illustrate how to remove the default OmniAuth identity pages once you've created your own.
-ra
This is great, really great. When create an application with authentication, i used the
devise. But, after that i will try to integrate the warden. There is a very intresting
point that move our authentication up into Rack middleware. Great!
Every time our eyes keep on your screencasts.
Thank you Ryan,
Am also receiving the same error
Nice Tutorial! I just want to post here a fix I discovered. Sorry if this would be a repost:
In your tutorial:
$('#products').html('<%= escape_javascript(render("products")) %>');
But in Rails 3.1, you have to explicitly define it as a partial:
$('#products').html('<%= escape_javascript(render :partial => "products" %>');
I hope this helps anyone who had the same issue. :)
Ryan - first of all thanks a lot for doing this episode. But I'm having a few problems implementing this.
Ryan - first of all thanks a lot for doing this episode. But I'm having a few problems implementing this.
Hi Ryan!
Great Episode!
Is there any possibility you could make an episode on jCrop with Paperclip?
Thanks Ryan for this awesome railscast....worked like a charm in my webapp. Is it possible to order the states by name?
Please 'revisit' this for Pro subscribers!
The sortable list revised screencast was GOLD.... would really appreciate a Rails 3.1 working example of polymorphic associations for Rails 3.1....
Guys anyone knows how to apply this sortable logic for associations.
For example, i have a table videos (id, name, video_category_id) and video_categories (id, name). I am displaying video name and video category name in a table. Now when someone wants to sort using video category name, it should sort records with video category name instead of using video category id from the association column in video table.
I prefer Dragonfly, but I really like how you approached this. Great timing too!
Helpful? I love you, man!
I get the following error:
SQLite3::SQLException: no such column: taggings.
Sadface.
How can we make a validation about the token field? Just, I want to validate presence of this field. Any idea?
Regards
(rails >= 3.1.1) When precompiling assets, shouldn't rails include both hashed and non-hashed version of the images?
+1 too!
I'm using rvm and have managed to deploy 1 app with a certain degree of success. I'm now struggling to deploy another where my gems are defined in a gemset. Unicorn seems to be expecting them in the global space. Any idea what I can stuff in my unicorn.rb to tell it to use my gemset in this instance?
Hey Ryan, great cast as usual. Karol's question above is still open, my Google searches thus far have not turned up any answer. Besides making a plugin, is there a place Rails 3 looks for custom generators outside of a Rails app as it did in Rails 2?
For those wanting to use this with Rails 3:
<%=
when using thecalendar_for
helper[1]
gem "table_builder", :git => "git://github.com/p8/table_builder.git"
- do not rely on the released gem, it seems to be stale.Thanks for this Ryan.
In your 'how I test' presentation, you use factory_girl_rails and guard-respec. Where do they belong in this setup? The Gemfile refers to the gemspec file, so should they go in the gem spec file? And can you use instructions like ,
:require => false if RUBY_PLATFORM =~ /darwin/i
If using Rails 3, see: http://rubygems.org/gems/acts_as_tree_rails3
I had all sorts of trouble getting the cropper changes to work. Firstly, you'll need to restart your Rails server every time you change the Paperclip changes.
Secondly, I couldn't really get the cropping code to work without putting quotes around the resize and cropping amounts. Because I always crop to a certain size, I completely replaced the array used in the transformation command.
Apologies for the Hungarian notation. Old programmer & bad habits die hard.
This would be a good one to revise.
especially if you put these into rspec
let
blocks:This is almost eerie. I was just now Googling around for an in-place edit solution in Rails... and suddenly it shows up as one of the latest Railscasts :). Awesome!
FYI - Devise no longer uses GET for the sign_out it uses DELETE. So you need to make your log out button/link use the DELETE method. Or change your route so to something like this which will use GET.
devise_scope :user do
get "/logout" => "devise/sessions#destroy"
end
great as usual
how can edit grid data?
i wanna using it to admin panel
Slightly OT question. Where did you get this comprehensive list of states/countries? I know many sources but they all require fair amount of work to import in rails db.
The hack does fix it, thanks.
Amaizing episode here. A railscast over cancellation/changing plans and other events like these that might happen would be awesome!
Thank you!
Excellent tutorial! And a huge thank you to Jakub for the Rails 3.1 help!
Also, don't forget that Rails.env is used instead of RAILS.ENV in rails 3!
Rails 3 do
I also set up my config file with defaults that are loaded into each environment to keep things DRY.
defaults: &defaults development: <<: *defaults test: <<: *defaults production: <<: *defaults
This would be a good one to revise.
Does this help? Fixed it for me.
https://github.com/sporkrb/spork/issues/151
Just noticed the same behaviour here, kinda weird.
Wow, coming up to 3 years old and this is still a super easy way of doing sorting by dragging. I have just used this approach alongside your brilliant nested attributes tutorials (http://railscasts.com/episodes/196-nested-model-form-part-1) and it works just as well as the simple model example you use in this tutorial.
For me I have a Page model with nested attributes on a Snippet model (all very CMS based). If anyone was thinking of doing the same, go for it. I did this - it may help you:
1 - added a controller for the nested model - "Snippet" in my case (not needed otherwise) which just contains the "sort" method as you have it i.e.
2 - add the drag n drop code to my show view rather than my index view like this:
it helped me to keep the sorting feature out of the way of the nested attribute feature in the edit view for my parent model
3 - since i am Rails 3.0.x based i have added a default_order scope to my nested model to handle the sorting bit:
4 - for Rails 3 i have also used the routing approach added by Tyler Gannon in these comments i.e.
all works a treat. thank you for your excellent work as always Ryan!
glenn
p.s. the great thing about all this is that it just works without messing about! i was especially happy that the sort method only acts on those "id's" that i am currently working within my "show" view and NOT all objects i.e. it updates the positions for those snippets in my current page, not all snippets. the acts_as_list gem is optional for me in that my position attribute is optional but i may also end up with several snippets with NO positions by default so i'd sooner have positions added by the acts_as_list gem on new snippets - even if the calculated 'next position' is not scoped to my current page model. it's no big deal because as soon as you reorder your snippets it all sorts itself out!