There's nothing wrong with that approach either. I think it depends on the specific use case.
I have both strategies in one of my apps. Visitor searches on the public site are not stored, but admin searches in the marketing module are because they provide the criteria for targeting a segment of a marketing list which is then used by a backend job to send emails. Since the list changes as subscribers come and go, having the list based on search criteria is essential.
So this type of advanced search definitely has it's use case. Thanks for the revision Ryan.
What's wrong with not having a database backend at all, configuring the attribute accessors manually and have the create action of the controller show the search result (after possible validations)? I guess re-using the search has its niceities, but how often will it actually get used in an average app?
Just a small comment on the pruning of old searches. I think it's generally bad behaviour to remove old searches. People might link to it, expect it to remain, and boom, suddenly it's gone.
It's probably better to check if a specific search already exists before creation and redirect to it if need be.
farukca: I just try to develop a file flowing. We have some papers comming from other companies. These files includes some unordered information. So somebody make ocr or writedown this unordered fields. And searching on it.
Hey Ryan! Thanks a lot!
I have a little problem here.
Do i have to make any changes in my controller? The view is perfect, but when I click "send", nothing is updated. Thanks!
I had used ElasticSearch with mebla gem, it was working so good and easy to configure on production. But I will try solr this time, because it's mongoid configuration is so simple.
Murat hocam, sen nerede kullanacaksın fulltext aramayı ?
Murat: Sunspot is a ruby wrapper for Solr. Another search engine to check out is ElasticSearch (and the Tire gem for it). It has some nice features like distributed indices for high availability and it's a lot easier than to set up than solr.
I finally had a chance to get back to this and discovered that tonight. After getting it working I came back here to let David know how I solved it. You are correct, the timeout is very low and at least for me running nginx/passenger/rails in dev mode is just too slow to respond. I changed the JS/CoffeeScript to:
I'm trying to use rack-pjax on the top div container and I can see the performance difference even the pushState reload whole body (header still loaded)
thanks for the railcast! as a noob, this is just what i have been looking for.
question.... the basic spree store that i got up and running seems to be missing a number of elements like the links for the shopping cart, search bar, etc.. and when you click on a product it goes to a blank page. this is different than what you illustrate here. i read that the basic spree install is basic... it just seems that the one i have set up is much more basic than the one illustrated. i would appreciate any advice or direction as to what i might be missing. i am using, spree 0.70.1, ruby-1.9.2-p290 and rails 3.1.1.
I don't know what happened, but restarting nginx and unicorn multiple seems to have solved the problem and it hasn't reappeared yet. I still wonder what caused it though.
I followed by letter the screencast tuto but got the below errors:
serge@serge-laptop:~/Development/Ruby/test_projects/blog$ guard
Please install libnotify gem for Linux notification support and add it to your Gemfile
Guard is now watching at '/home/serge/Development/Ruby/test_projects/blog'
Starting Spork for RSpec & Cucumber
Using RSpec
Using Cucumber
Preloading Rails environment
Preloading Rails environment
Loading Spork.prefork block...
Loading Spork.prefork block...
ERROR: Could not start Spork server for RSpec & Cucumber. Make sure you can use it manually first.
Guard::RSpec is running, with RSpec 2!
Running all specs
No DRb server is running. Running in local process instead ...
No examples found.
Finished in 0.71765 seconds
0 examples, 0 failures
Spork is ready and listening on 8989!
Spork is ready and listening on 8990!
Any ideas as to why I receive the following error message when I run rake db:bootstrap --trace per the instructions in the readme for this episode?
This task will destroy any data in the database. Are you sure you want to
continue? [y/n] y
rake aborted!
undefined method set_preference' for nil:NilClass
/home/family/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/whiny_nil.rb:48:inmethod_missing'
/home/family/.rvm/gems/ruby-1.9.2-p290/gems/spree_core-0.70.1/lib/spree/preference_access.rb:18:in block in set'
/home/family/.rvm/gems/ruby-1.9.2-p290/gems/spree_core-0.70.1/lib/spree/preference_access.rb:17:ineach'
/home/family/.rvm/gems/ruby-1.9.2-p290/gems/spree_core-0.70.1/lib/spree/preference_access.rb:17:in set'
/home/family/Desktop/APPS/Episodes/EPISODES/ryanb-railscasts-episodes-8f0f990/episode-298/store-after/config/initializers/spree_config.rb:1:in'
Hey, I'm having trouble with redirecting. I have the same nginx.conf as in the tutorial, and when I do redirect_to posts_path in my controller, I get redirected to http://unicorn/posts, instead of http://example.com/posts. What could've I missed?
Even if I do just redirect_to '/', I get redirected to http://unicorn/.
First of all thanks for the great work about nested objects. When i tried your example in my application IE gave me an error that object does not support method for jQuery hide() method. I did everything to figured out problem but none of them worked.
-copied jquery files to /assets/javascripts did not work !
-copied content of jquery.js file to application.js did not work!
-changed application.html.erb file like this
<%= javascript_include_tag "jquery","application", :cache=>true %> did not work.
@Ryan: yet again you've done a great tutorial job. Thanks for covering this episode with Spree. In version 0.80, we plan to have the namespace for the sake integration with other such as RefineryCMS. I hope you will create another tutorial on Spree integration.
Maybe the request is just meeting a timeout, in which case it falls back to a normal request. You can configure the timeout delay, which is by default 650ms.
Tried this with locations for a new event. It was working fine then I deleted a location and it keeps trying to download a json file instead of displaying the index. Any ideas?
Log: Started GET "/locations" for 192.168.. at 2011-11-15 14:20:10 -0500
Processing by LocationsController#index as HTML
[1m[35mLocation Load (3.2ms)[0m SELECT "locations".* FROM "locations"
[1m[36mLocation Load (2.0ms)[0m [1mSELECT "locations".* FROM "locations" WHERE (name like '%%') ORDER BY name[0m
Completed 200 OK in 89ms (Views: 7.8ms | ActiveRecord: 8.4ms)
In case anyone gets stumped by
task.save(false)
, as of rails 3 usetask.save(validate: false)
.See 3.0 release notes:
save(false) is deprecated, in favor of save(:validate => false)
and the API.The related error you may see is
Can I integrate ActiveAdmin in views/layout/application.html.erb
<html><head>
<title> .... </title>
</head><body>
...
<div class="active_admin">
active_admin yield
</div>
...
</body>
</html>
nice piece of app. I finally get it right. Thanks, I've been looking for this for a month already.
good job!
i have one question.. method 'data:', is only in rails 3.1 ?
Is this railscast still relevant?
I read that I need to use find(:all) now for 3.1
There's nothing wrong with that approach either. I think it depends on the specific use case.
I have both strategies in one of my apps. Visitor searches on the public site are not stored, but admin searches in the marketing module are because they provide the criteria for targeting a segment of a marketing list which is then used by a backend job to send emails. Since the list changes as subscribers come and go, having the list based on search criteria is essential.
So this type of advanced search definitely has it's use case. Thanks for the revision Ryan.
Using it for my puppy project, flows smoothly now after some tinkering :-)
https://github.com/RobertBrewitz/articulated
I have a weird issue...
calendar is generating for all articles in my blog e.g. I have 5 articles so each article has own calendar on main page.
<%= calendar_for @articles do |calendar| %>
<%= calendar.head('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')%>
<% calendar.day(:day_method => :published_at) do |date, articles| %>
<%= date.day %>
<% end %>
<% end %>
I'm using rails 3.1
How to fix it?
Hi, receiving the following error when clicking my "Log In" link:
Routing Error
undefined method `username_attribute_name=' for #Sorcery::Model::Config:0x41a2730
What's wrong with not having a database backend at all, configuring the attribute accessors manually and have the create action of the controller show the search result (after possible validations)? I guess re-using the search has its niceities, but how often will it actually get used in an average app?
I got testing with rspec working here, note that I am using mongo(oid) and not ActiveRecord (same principle though):
https://github.com/RobertBrewitz/EngineRspecMongoid
NOTE: I think I found some bug in the rails plugin new generator with camel casing. More here: https://github.com/rails/rails/issues/3684
Just a small comment on the pruning of old searches. I think it's generally bad behaviour to remove old searches. People might link to it, expect it to remain, and boom, suddenly it's gone.
It's probably better to check if a specific search already exists before creation and redirect to it if need be.
Hi Ryan,
you should use »rails generate sorcery:install« instead of »sorcery:bootstrap«.
Have fun!
Thank you Daniel.
I will just look at ElasticSearch with Tire gem. I assume that i would integrate ElasticSearch in my project.
farukca: I just try to develop a file flowing. We have some papers comming from other companies. These files includes some unordered information. So somebody make ocr or writedown this unordered fields. And searching on it.
Hey Ryan! Thanks a lot!
I have a little problem here.
Do i have to make any changes in my controller? The view is perfect, but when I click "send", nothing is updated. Thanks!
I had used ElasticSearch with mebla gem, it was working so good and easy to configure on production. But I will try solr this time, because it's mongoid configuration is so simple.
Murat hocam, sen nerede kullanacaksın fulltext aramayı ?
Murat: Sunspot is a ruby wrapper for Solr. Another search engine to check out is ElasticSearch (and the Tire gem for it). It has some nice features like distributed indices for high availability and it's a lot easier than to set up than solr.
What could also speed up your process is to tell your specs to halt after first failure:
Thank you Ryan for this advanced search screencast.
Is there any suggestion for us about fulltext search engines? In Ryan`s screencasts, before,
he show us Sphinx and Sunspot, what about Solr?
Regards.
Thanks VonD,
I finally had a chance to get back to this and discovered that tonight. After getting it working I came back here to let David know how I solved it. You are correct, the timeout is very low and at least for me running nginx/passenger/rails in dev mode is just too slow to respond. I changed the JS/CoffeeScript to:
Now it's working find :)
i am getting this error when try to run sudo service unicorn restart
/usr/bin/env ruby-local-exec no such file or direcotry
i am using rbenv and have done 'rbenv local 1.9.2-p290' in my project
what can be the issue?
I'm trying to use rack-pjax on the top div container and I can see the performance difference even the pushState reload whole body (header still loaded)
ryan,
thanks for the railcast! as a noob, this is just what i have been looking for.
question.... the basic spree store that i got up and running seems to be missing a number of elements like the links for the shopping cart, search bar, etc.. and when you click on a product it goes to a blank page. this is different than what you illustrate here. i read that the basic spree install is basic... it just seems that the one i have set up is much more basic than the one illustrated. i would appreciate any advice or direction as to what i might be missing. i am using, spree 0.70.1, ruby-1.9.2-p290 and rails 3.1.1.
thanks,
bob
I don't know what happened, but restarting nginx and unicorn multiple seems to have solved the problem and it hasn't reappeared yet. I still wonder what caused it though.
I followed by letter the screencast tuto but got the below errors:
Any idea about the error? Thanks
Has anyone else noticed that http://guides.rubyonrails.org/initialization.html isn't in the guides index? Would've been helpful to have that link a year ago!
It works but somehow mine seems slower than Ryan's. Am I missing something or did he do some creative video editing? ;)
Any ideas as to why I receive the following error message when I run rake db:bootstrap --trace per the instructions in the readme for this episode?
This task will destroy any data in the database. Are you sure you want to
continue? [y/n] y
rake aborted!
undefined method
set_preference' for nil:NilClass
method_missing'/home/family/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/whiny_nil.rb:48:in
/home/family/.rvm/gems/ruby-1.9.2-p290/gems/spree_core-0.70.1/lib/spree/preference_access.rb:18:in
block in set'
each'/home/family/.rvm/gems/ruby-1.9.2-p290/gems/spree_core-0.70.1/lib/spree/preference_access.rb:17:in
/home/family/.rvm/gems/ruby-1.9.2-p290/gems/spree_core-0.70.1/lib/spree/preference_access.rb:17:in
set'
'/home/family/Desktop/APPS/Episodes/EPISODES/ryanb-railscasts-episodes-8f0f990/episode-298/store-after/config/initializers/spree_config.rb:1:in
Forget my comment above. It's working. Not sure what i was doing wrong. I updated the project to use bundler and it works fine. Thanks.
Hey, I'm having trouble with redirecting. I have the same nginx.conf as in the tutorial, and when I do
redirect_to posts_path
in my controller, I get redirected tohttp://unicorn/posts
, instead ofhttp://example.com/posts
. What could've I missed?Even if I do just
redirect_to '/'
, I get redirected tohttp://unicorn/
.Wow... eye opening... I, as well, would love another one of these.
Hi Ryan,
I'm trying to get your example to work, but having no luck with content_for. There is never any content added in the layout where you have
<%= yield :head %>
I pulled the latest code off github and having the same issue.
How about seeing to integrating into existing app. Thanks for screencast! Great job!
I used this script to install Image Magick on previous applications, seemed to work good: https://github.com/maddox/magick-installer
Ok guys I figured out my above problem, had to enable IPN for my paypal account.
Thanks
Rohan
Thank!
See also :
http://harvesthq.github.com/chosen/
http://github.com/christianblais/searchify
Thank you Ryan,
In fact, with Active Reload the server is really fast in production mode.
Thanks
I haven´t got the cropper module to work with Ryans code, but this works for me
What about doing stubs and mock objects for request specs? I know it's possible in FactoryGirl but I never quite got the hang of it
Is IPN working for anyone? I am not receiving IPN on payment made or for the recurrence.
My sandbox application is available on externally accessible domain.
Any help on this?
Thanks
Rohan
Sorttable is ridiculously easy to use, unobtrusive, and doesn't require all those http requests.
Thanks for the suggestion!
Hello Ryan,
First of all thanks for the great work about nested objects. When i tried your example in my application IE gave me an error that object does not support method for jQuery hide() method. I did everything to figured out problem but none of them worked.
-copied jquery files to /assets/javascripts did not work !
-copied content of jquery.js file to application.js did not work!
-changed application.html.erb file like this
<%= javascript_include_tag "jquery","application", :cache=>true %> did not work.
My rails version 3.1.0
thanks..
Great episode Ryan!
It would be AWESOME if you could go into more depth in stripe, even if it is with the pro subscription. It would be very very useful.
Thanks!
@Ryan: yet again you've done a great tutorial job. Thanks for covering this episode with Spree. In version 0.80, we plan to have the namespace for the sake integration with other such as RefineryCMS. I hope you will create another tutorial on Spree integration.
The best way i've found to do this is to just add a route in your routes file like:
Then create a new controller that inherits from MercuryController, like:
Then, you can get all the functionality of Mercury, but limit access on requests like that. That might be a bit closer to what you were looking for.
Oh, and be sure to add that route before the mercury routes in your routes.rb file
Maybe the request is just meeting a timeout, in which case it falls back to a normal request. You can configure the timeout delay, which is by default 650ms.
Tried this with locations for a new event. It was working fine then I deleted a location and it keeps trying to download a json file instead of displaying the index. Any ideas?
Log:
Started GET "/locations" for 192.168.. at 2011-11-15 14:20:10 -0500
Processing by LocationsController#index as HTML
[1m[35mLocation Load (3.2ms)[0m SELECT "locations".* FROM "locations"
[1m[36mLocation Load (2.0ms)[0m [1mSELECT "locations".* FROM "locations" WHERE (name like '%%') ORDER BY name[0m
Completed 200 OK in 89ms (Views: 7.8ms | ActiveRecord: 8.4ms)
In addition to being a great video overall, it also just introduced me to
tap
. Thanks Ryan :)