Such an amazong epsiode. I was reading on this full text searching for PostgreSQL before, but I didn't understand quite a lot of things, and this really cleared things up. Thank you so much :)
Hwaaaa! Awsome timing. I just started adding Sphinx to my application, and I'm already using Postgres. For my particular needs, Postgres apparently offers more than enough. Thanks again very much Ryan.
Great screencast, I was using texticle already but this has given me much more flexibility.
Has anybody else ran into an error when creating the unaccent extension? I'm running rails 3.2, I've had no problems elsewhere in this screencast for some reason or other its not liking this migration, I've triple check the syntax
ruby
== AddUnaccentExtension: migrating ===========================================
-- execute("create extension unaccent")
rake aborted!
An error has occurred, this and all later migrations canceled:
PG::Error: ERROR: syntax error at or near "extension"LINE1: create extension unaccent
^
: create extension unaccent
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Found an even better way to do it! It's in the readme for the jquery-datatables-rails gem:
Twitter Bootstrap 2 support
Add the JavaScript to application.js:
//= require dataTables/jquery.dataTables.bootstrap
Remove the initial stylesheets from application.css
Add the stylesheets to application.css:
*= require dataTables/jquery.dataTables.bootstrap
Initialize your datatables like this:
// For fluid containers
$('.datatable').dataTable({
"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
"sPaginationType": "bootstrap"
});
Amazing how much simpler this is, especially since the power shown in the unrevised editions is one of the thing that made me think Ruby was so much better than the alternatives. Thanks, Ryan!
Thank you for your feedback. I am guilty of not providing enough documentation.
Since the gem was mostly used on internal projects, like tr8n admin tools and others, i never did my part on documenting it.
Well, i am fixing this now. Here is a document on customizing the table view:
This was one of the first casts that got me into Railscasts so I'm glad to see an update.
Just a word of caution to new users of this technique: when you have a hammer everything can look like a nail. Dynamic nested forms like this are extremely powerful and can sometimes grant the user too many chances to input bad data.
If you find yourself needing complex validations to regulate the the data coming in from the form, a solution like this might not be what's in order and you might want to limit the scope of what is possible to do. Ryan's simple example here is spot on.
This dynamic nested form technique has worked wonders for me (Thanks, Ryan!) but I've been bitten by applying it to the wrong use cases-- use discretion when deciding on a UX.
I re-use the same function for inserts that i do for updates and just call it differently inside the trigger. The only real bit of duplication is the refresh function - which i have for existing content only.
Nice episode, but I would recommend to set Http-only setting for auth-cookies so if site somehow have xss hole attacker cannot steal cookies through javascript.
FYI, I was able to have the same styling on the f.button when omitting 'btw' from :class, since 'btn' is one of the default classes the Twitter Bootstrap-powered version of SimpleForm has (defined in config/initializers/simple_form.rb):
products/_form.html.erb
<%= f.submit nil, :class => 'btn-primary'%>
Can leave out 'btn' from :class because its specified here:
config/initializers/simple_form.rb
# Default class for buttons
config.button_class = 'btn'
Thanks for the episode. I followed along and everything worked as expected (I did have to take aharte's advice to move /usr/local/bin above /usr/bin in /etc/paths to get 9.1.3 recognized).
However when I run "rails db" and try any commands against postgres I get a segmentation fault: 11. I installed postgres with the > brew install postgresql used in the railscast. I'm on Lion and > psql --version returns "psql (PostgreSQL) 9.1.3"
Heroku's db:pull functionality was formerly based on yaml_db and has since moved to taps. I have had less problems with taps, though, i've used yaml_db to change schema in mass on existing data.
It suggests replace complex ActiveRecord logic with SQL to gain performance boost. The examples such as act_as_tree are impressing. The major disadvantage is that you can no more change db adapter easily.
I am using will_filter since a few days and it seems like a really helpful gem. My favorite feature is that you can combine saved filters to new filters. There is not that much documentation on customization but code to look into. A good starting point is the dummy application or parts of tr8n.
This was fixed very recently. It works if you use the newest commit (as of right now):
Same OS & Browser, same results.
If you want more flexibility, try awesome_nested_fields. =)
I like your approach. Thanks for sharing.
Such an amazong epsiode. I was reading on this full text searching for PostgreSQL before, but I didn't understand quite a lot of things, and this really cleared things up. Thank you so much :)
May I ask how I can get the cache monitor at the bottom of the screen?
Use Cocoon :) https://github.com/nathanvda/cocoon
You might need to reinstall the pg gem, possibly with pg config path specified http://deveiate.org/code/pg/
Is it possible to have condition clause in searching like has clause in thinking sphinx ?
Cocoon is cool
Thank you Ryan. I like this nested model forms that starting from scratch. This is awesome.
+1
How do i get it to work with simple form?
Hwaaaa! Awsome timing. I just started adding Sphinx to my application, and I'm already using Postgres. For my particular needs, Postgres apparently offers more than enough. Thanks again very much Ryan.
Very nice cast. That pipeline can get convoluted. Thank you!
Does this mean if we switch to postgres from mysql, we no longer need solr or sphinx anymore?
I actually feel good about spending the $9 per month for episodes like this! That's a big statement considering how cheap I am.
+1
Great screencast, I was using texticle already but this has given me much more flexibility.
Has anybody else ran into an error when creating the unaccent extension? I'm running rails 3.2, I've had no problems elsewhere in this screencast for some reason or other its not liking this migration, I've triple check the syntax
Found an even better way to do it! It's in the readme for the jquery-datatables-rails gem:
Twitter Bootstrap 2 support
Add the JavaScript to application.js:
//= require dataTables/jquery.dataTables.bootstrap
Remove the initial stylesheets from application.css
Add the stylesheets to application.css:
*= require dataTables/jquery.dataTables.bootstrap
Initialize your datatables like this:
// For fluid containers
$('.datatable').dataTable({
"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
"sPaginationType": "bootstrap"
});
// For fixed width containers
$('.datatable').dataTable({
"sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
"sPaginationType": "bootstrap"
});
https://github.com/rweng/jquery-datatables-rails
Amazing how much simpler this is, especially since the power shown in the unrevised editions is one of the thing that made me think Ruby was so much better than the alternatives. Thanks, Ryan!
+1
Thank you for your feedback. I am guilty of not providing enough documentation.
Since the gem was mostly used on internal projects, like tr8n admin tools and others, i never did my part on documenting it.
Well, i am fixing this now. Here is a document on customizing the table view:
https://github.com/berk/will_filter/wiki/Customizing-Table-View
Wow, I moved to pg over a year ago so I could use Heroku. I never even knew it would help me with search. I have some code to update. Thanks!
Every time I think I really know what I'm doing in rails you humble me. This is so simple and useful, and I didn't know it. Thanks so much!
Works in HTML5, is cut off with Flash.
OSX Lion with Chrome 19.
I'm using Cocoon... it seems pretty good so far.
thanks Ryan...
@anyone Does anyone have an example carrierwave intregration (file or image upload in in a nested model)
I think you should have mentioned Cocoon
This was one of the first casts that got me into Railscasts so I'm glad to see an update.
Just a word of caution to new users of this technique: when you have a hammer everything can look like a nail. Dynamic nested forms like this are extremely powerful and can sometimes grant the user too many chances to input bad data.
If you find yourself needing complex validations to regulate the the data coming in from the form, a solution like this might not be what's in order and you might want to limit the scope of what is possible to do. Ryan's simple example here is spot on.
This dynamic nested form technique has worked wonders for me (Thanks, Ryan!) but I've been bitten by applying it to the wrong use cases-- use discretion when deciding on a UX.
http://stevehodgkiss.com/posts/testing-rails-3-generators-with-rspec
I know this is old... But it made my day!
There was an earlier episode on MongoDB here.
The PostgreSQL notices in the console really annoy me. You can turn them off by adding
min_messages: warning
in your database.yml file. See exampleThe example I have is something like:
http://omarqureshi.net/articles/2010-12-25-tsearch2-for-rails-applications
I re-use the same function for inserts that i do for updates and just call it differently inside the trigger. The only real bit of duplication is the refresh function - which i have for existing content only.
Nice episode, but I would recommend to set Http-only setting for auth-cookies so if site somehow have xss hole attacker cannot steal cookies through javascript.
how about MongoDB? what's the Pro/Cons?
would love an episode on mongoDB
FYI, I was able to have the same styling on the
f.button
when omitting 'btw' from:class
, since 'btn' is one of the default classes the Twitter Bootstrap-powered version of SimpleForm has (defined inconfig/initializers/simple_form.rb
):<%= f.submit nil, :class => 'btn-primary' %>
Can leave out 'btn' from
:class
because its specified here:Thanks for the episode. I followed along and everything worked as expected (I did have to take aharte's advice to move /usr/local/bin above /usr/bin in /etc/paths to get 9.1.3 recognized).
However when I run "rails db" and try any commands against postgres I get a segmentation fault: 11. I installed postgres with the > brew install postgresql used in the railscast. I'm on Lion and > psql --version returns "psql (PostgreSQL) 9.1.3"
Any thoughts on the segmentation fault?
Thanks.
andreteves, did you have any luck resolving this issue? I'm getting the same error?
Thanks.
That last one was some nice trick!
Helpful for me. It's nice to have a visual walkthrough so I can see it step by step, especially since I'm new.
The veil is lifted.
(But yes, that's probably the right answer)
Ubuntu 12.04 with Chromium 18.0.1025.151:
Works fine with HTML5 and cuts with Flash, so no worries :)
Heroku's
db:pull
functionality was formerly based on yaml_db and has since moved to taps. I have had less problems with taps, though, i've used yaml_db to change schema in mass on existing data.Albino has been deprecated in favor of pygments.rb. This code combines both redcarpet 2.1 and pygments.rb
Bouh!
This is easy to understand:
foo
package provides binary executable of foo.foo-dev
package contains header(.h) and library(.so) files for compiling related sources.Since
pg
gem is a native gem that needs to be compiled against pg library, you needlibpq-dev
.And I want to point out a PGCon2009 video: PostgreSQL as a secret weapon for high-performance Ruby on Rails applications.
It suggests replace complex ActiveRecord logic with SQL to gain performance boost. The examples such as
act_as_tree
are impressing. The major disadvantage is that you can no more change db adapter easily.A simple note:
pg
gem uses prepare statement in production env by default, which is different from MySQL.This can be an issue if you are using unicorn. You may got
PGError: ERROR: prepared statement "a3" already exists
after several requests.To solve this, make sure each unicorn process uses its own database connection by adding this to unicorn config file:
Hope this helps :)
I am using will_filter since a few days and it seems like a really helpful gem. My favorite feature is that you can combine saved filters to new filters. There is not that much documentation on customization but code to look into. A good starting point is the dummy application or parts of tr8n.