RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

Akshay Rawat 's post that refers to a video where all of my worries are presented along the reasons why I havent done much more than design and prototypes apps with document based DB and never in production.

Avatar

Well i have had the same problems she is talking about at the design face, i have never implemented document base db because of all she said. Still i think things are changing because most node.s projects use mongodb and node.js's community is growing very fast.

Avatar

Subscribed just for this episode so I do this the best way. Thanks!

Avatar

An interesting talk at RubyConf on why Diaspora went from MongoDB to MySQL.

Avatar

You are both right and wrong. Redis is a memory-only key-value store, but you are free to specify dump intervals in your redis config where it saves its contents to disk. Check the docs for more.

Avatar

Fyi, the mongoid_ancestry gem provides nearly the same feature set as the ancestry gem for active_record, but for mongoid. It has some gotchas but worth to check out.

Avatar

However, there's been more out-of-the-box support for mongoid among popular authentication gems... If you want to introduce that type of logic with MongoMapper while doing very little typing in your text editor and still watch it all work, I recommend checking out Sorcery as a starting point. Sorcery jives with MongoMapper way better than things like Clearance or Devise. Obviously there's a gem for that but we've lost track of the the point here, because the real question we ought to consider is the extent ORMs are appropriate for engaging NoSQL data structures from Ruby. Maybe I'm missing something but it's tough for me to distinguish the key value store pattern from array or the ruby hash key/entry. Isn't MongoDB's driver the most natural map to data objects we handle in ruby? I tell you all, if it weren't for free validation methods and some active model hooks I wouldn't be able to care about Mongo ORMs.

Avatar

Radha, check out my 2nd favorite ORM in the world: MongoMapper! 2nd only to Active Record! :)

Avatar

The VPS I'm using is Media Template. Apparently they mount /tmp with noexec.. To resolve this;

Shell Commands
umount /tmp;
su deployer
mkdir ~/tmp
exit
mount --bind ~/tmp /home/deployer/tmp

then go back and run rbenv install 1.9.3-p125 again.
Once done, just umount and reboot for it to put /tmp back as a noexec..

I tried to remove the noexec and remount but it wouldn't let me.. shrug

Avatar

Hey guys, I have followed the instructions to the line.. I got to here;

deployer@ve:~$ rbenv install 1.9.3-p125

Shell Output
Downloading http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz...
Installing yaml-0.1.4...

BUILD FAILED

Inspect or clean up the working tree at /tmp/ruby-build.20120728204839.7741
Results logged to /tmp/ruby-build.20120728204839.7741.log

Last 10 log lines:
yaml-0.1.4/win32/vs2008/run_parser.vcproj
yaml-0.1.4/win32/vs2008/yaml.vcproj
yaml-0.1.4/win32/vs2008/test_version.vcproj
yaml-0.1.4/win32/vs2008/run_emitter.vcproj
yaml-0.1.4/win32/vs2008/example_reformatter.vcproj
yaml-0.1.4/win32/vs2008/run_loader.vcproj
yaml-0.1.4/win32/vs2008/yamldll.vcproj
yaml-0.1.4/win32/config.h
/tmp/ruby-build.20120728204839.7741/yaml-0.1.4 /tmp/ruby-build.20120728204839.7741 ~
/home/deployer/.rbenv/plugins/ruby-build/bin/ruby-build: ./configure: /bin/sh: bad interpreter: Permission denied

... little help?

Avatar

Thanks Ryan great episode as always.

What i find a bit hard to implement in document base DB are trees and has_many through associations.

Avatar

In wich differs the revised episode from this one? I might do my first subscription purchase if you give a good reason :)

btw, thanks for all these screencasts, you are awesome Mr. Ryan Bates!

Avatar

i'm trying to render a partial form in a show view but it doesn't render it, do you know why would this be?

Avatar

do you happen to have the mysql gem as well in your gem file?

Avatar

I may be confused on the Twitter Secret & Consumer keys... but should these values be stored in a hash?

In the unfortunate event of a database being hacked - wouldn't that give access to post on user's Twitter accounts?

Avatar

This is horrendous - by the time you had written all the regex's for every bit of your code you could have written tests by hand much quicker. It is like you are making up regex'sa to explain english statements instead of logically doing something - seems really convoluted to me.

Am I not getting something? I was checking all over to see if this was a practical joke or something.

Avatar

Hello everyone,

I followed the tutorial and got fb-connect working with localhost:3000. I am using version 1.4.0 as suggested in the comment above and am not using javascript popup. Now, when I uploaded my work on development server and click "sign in with facebook", I get

No route matches [GET] "/auth/facebook"

The only difference between localhost and dev server is the app on dev server has dev.mydomain.com:3000 as its domain and that's the domain I entered on fb app setting page. Is having a subdomain the problem? Any help would be appreciated.

Here are gems on both my localhost and dev server. Thanks!

Using oauth2 (0.8.0)
Using omniauth (1.1.0)
Using omniauth-oauth2 (1.0.3)
Using omniauth-facebook (1.4.0)

Avatar

I'm not sure if I'm understanding your question correctly. You could call @user.gender in the view if you want to put the array in a method.

Avatar

me too, I'm using postgres

$ gem list pg
*** LOCAL GEMS ***
pg (0.14.0)

How I do fix that?

Avatar

Hi Ryan, Indeed great screencast.

What would be the case if I dont want to specify the gender array in the /users/show.html.erb page as collection: [["Male", "Male"], ["Female", "Female"], ["", "Unspecified"]]

but rather define an array in the gender action inside the user class and reference it on show page?

def gender
['Male', 'Female']
end

and how to call these in the index using best_in_place syntax?

Thanks,

Avatar

yeah, that is not going to work, you are going to need to pull the whole tree

Avatar

Fantastic Episode! I never knew that just by moving the position of the javascript tag in the Layout File you could accomplish so much! This is really useful! Thank you Mr. Bates

Avatar

Just logged in to post this gotcha too, but then I saw your comment.
This should be added to rails guides and definitely to release notes or something...

Avatar

had the same issue and was stuck for hours. issue is with font awesome, here's the solution: https://github.com/seyhunak/twitter-bootstrap-rails/issues/292

Avatar

Unfortunately, I couldn't ran this on my Project:
gems/rack-mini-profiler-0.1.7/lib/mini_profiler/storage/memory_store.rb:17:in block in initialize': private methodcleanup_cache' called for #Rack::MiniProfiler::MemoryStore:0x00000003bcb670 (NoMethodError)

The line of this error:
https://github.com/SamSaffron/MiniProfiler/blob/master/Ruby/lib/mini_profiler/storage/memory_store.rb#L17

I tried with FileStorage too:
gems/rack-mini-profiler-0.1.7/lib/mini_profiler/storage/file_store.rb:43:in block in initialize': undefined methodinstance' for Rack::MiniProfiler:Class (NoMethodError)

My project is running Rails 3.2.7 with ruby 1.9.3-p194

Avatar

Hello Sam,

I use the latest github profiler.rb from miniprofiler, after that my error changed as follows

index
Internal Server Error
undefined method `use_existing_jquery' for #<Rack::MiniProfiler::Config:0x000008061b9c80>
WEBrick/1.3.1 (Ruby/1.9.2/2011-02-18) 

and the console is

log
[2012-07-27 16:02:36] ERROR NoMethodError: undefined method `use_existing_jquery' for #<Rack::MiniProfiler::Config:0x000008061b9c80>
        /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rack-mini-profiler-0.1.7/lib/mini_profiler/profiler.rb:396:in `get_profile_script'
        /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rack-mini-profiler-0.1.7/lib/mini_profiler/profiler.rb:294:in `call'
        /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/railties-3.0.15/lib/rails/application.rb:168:in `call'
        /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/railties-3.0.15/lib/rails/application.rb:77:in `method_missing'
        /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/railties-3.0.15/lib/rails/rack/log_tailer.rb:14:in `call'
        /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rack-1.2.5/lib/rack/content_length.rb:13:in `call'
        /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rack-1.2.5/lib/rack/handler/webrick.rb:52:in `service'
        /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
        /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
        /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

How can i help you solving this problem? also thank you for your dealing..

Avatar

thanks for that link, some excellent tips from that guy

Avatar

can you try the latest from github to see if it fixes it?

Avatar

at the moment there is no support for rack 1.2.5, I am going to see what is involved in backporting

Avatar

I wonder if we could use multiple containers for pjax. so when a link in div 'one' has clicked, the content in the div 'two' loaded.

Avatar

I installed miniprofiler as Ryan said. But, the miniprofiler don`t show itself in the index.

My Rails version is 3.0.15 and Ruby version is 1.9.2p180.

When running the rails with server mode, it gives me a

index
Internal Server Error

undefined method `bytesize' for #<ActionDispatch::Response:0x000008079989f0>
WEBrick/1.3.1 (Ruby/1.9.2/2011-02-18) 

and the console log.

log
[2012-07-27 11:02:49] ERROR NoMethodError: undefined method `bytesize' for #<ActionDispatch::Response:0x0000080409add8>
        /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rack-mini-profiler-0.1.7/lib/mini_profiler/body_add_proxy.rb:18:in `method_missing'
        /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rack-1.2.5/lib/rack/utils.rb:276:in `bytesize'
        /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rack-1.2.5/lib/rack/content_length.rb:22:in `block in call'
        /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rack-1.2.5/lib/rack/content_length.rb:22:in `each'
        /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rack-1.2.5/lib/rack/content_length.rb:22:in `inject'
        /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rack-1.2.5/lib/rack/content_length.rb:22:in `call'
        /usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rack-1.2.5/lib/rack/handler/webrick.rb:52:in `service'
        /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
        /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
        /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

After that, i running the system from apache/passenger, but still, i couldn`t see the profiler in index, i see the index page source, it give me

html
</html>
<script type="text/javascript">    
    (function(){
        var init = function() {        
                var load = function(s,f){
                    var sc = document.createElement('script');
                    sc.async = 'async';
                    sc.type = 'text/javascript';
                    sc.src = s;
                    var l = false;
                    sc.onload = sc.onreadystatechange  = function(_, abort) {
                        if (!l && (!sc.readyState || /loaded|complete/.test(sc.readyState))) {
                            if (!abort){l=true; f();}
                        }
                    };

                    document.getElementsByTagName('head')[0].appendChild(sc);
                };                
                
                var initMp = function(){
                    load('/mini-profiler-resources/includes.js?v=104',function(){
                        MiniProfiler.init({
                            ids: ["p5a937ewxrrubs0tac38","qey8rl644x2an5x5d6p4","j5um9hugszmuwqk2ohos","7yowrrf5jgiuyr1qay8b","1t75jjzqgolxrdfwh84r","tm9zo7oshjqbvotg9bkm","i4fta5g96t7bfhmi2ifn","xvrw6jdradhpjepdjtb9","dv8soit19h1xro0s0kij","opbu5ya5fgt5mbhbjies","optspv3v29mlw0go62q7"],
                            path: '/mini-profiler-resources/',
                            version: '104',
                            renderPosition: 'left',
                            showTrivial: false,
                            showChildrenTime: false,
                            maxTracesToShow: 10,
                            showControls: false,
                            currentId: 'p5a937ewxrrubs0tac38',
                            authorized: true
                        });
                    });
                };
                if (false) {
                    jQueryMP = jQuery;
                    initMp();
                } else {
                    load('/mini-profiler-resources/jquery.1.7.1.js?v=104', initMp);
                }
                
        };

        var w = 0;        
        var f = false;
        var deferInit = function(){ 
            if (f) return;
            if (window.performance && window.performance.timing && window.performance.timing.loadEventEnd == 0 && w < 10000){
                setTimeout(deferInit, 100);
                w += 100;
            } else {
                f = true;
                init();
            }
        };
        if (document.addEventListener) {
            document.addEventListener('DOMContentLoaded',deferInit);
        }
        var o = window.onload;
        window.onload = function(){if(o)o; deferInit()};
    })();
</script>

Profiler, javascript code after the

html
</html> 

tag..

So, i could not still see the profile.. bad.. so bad.

Avatar

Is there a plan to support mongoid?

Avatar

Came back here five years later to remind myself how to do this. Thanks Ryan. Thank you very much

Avatar

Has anyone successfully integrated individual column filtering (preferably with multiple columns) with a Rails back end?

Thanks a lot.

Avatar

Many thanks. that did the trick. What an awesome tool!

Avatar

Meaning declaring the model attributes with attr_accessible? If that is what you are asking, yes I am.

Avatar

Try to clearing all browsing cache. It should work fine.

Avatar

yes, please do, with any relevant logs!

Avatar

it should work on both, are you whitelisting your requests?

Avatar

I need to figure out a way to backport some of this to rack 1.2.5, at the moment it depends on a later rack

Avatar

Great info, thank you.

It would have helped a novice like me to know that I needed to restart the rails server before "When we reload the page now our table looks quite different."

Also, I saw two places where products.js is mentioned without the .coffee

Avatar

I wasn't aware that

gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'

was valid bundler syntax, I thought it was :git. Is there a difference between the two? I can't exactly google the issue due to white noise.

Avatar

Typo in ASCII-Cast

terminal
$ mkdir ~/.ec2
$ mv ~/Downloads/gsg-keypair.gem ~/.ec2/gsg-keypair
$ chmod 600 ~/.ec2/gsg-keypair

gsg-keypair.gem should be gsg-keypair.pem

Avatar

@Sam
This is very promising. I am following Ryan's screencast and everything works fine on my dev machine, but I do not see the Profiler Tab in my production environment on my local machine. Is there something different in your local gem?
Thanks.
Bharat

Avatar

Problem

I've been fighting with that one for a while now. That is the cry for help. As suggested I've going through all the commands and executed them on the remote server.
The command that fails on the server is:

sh -c "rm -rf /home/deployer/apps/blog/releases/20120726142915/public/assets &&\\\n        mkdir -p /home/deployer/apps/blog/releases/20120726142915/public &&\\\n        mkdir -p /home/deployer/apps/blog/shared/assets &&\\\n        ln -s /home/deployer/apps/blog/shared/assets /home/deployer/apps/blog/releases/20120726142915/public/assets"

It says: \n not found. As far as I can tell, it doesn't like the new lines. When I put them away manually - everything goes OK.

The interesting this is - the deployment script seem to execute this command OK, and it is the next one it stables upon (bundle install). Although when executing manually on the sever - bundles get installed OK.

What can it be? And how, and where, do I edit those new lines "\\n" out?

Complete Output:

λ config → λ git master → cap deploy:cold
  * executing `deploy:cold'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote git@github.com:andremaha/blog.git master"
    command finished in 4916ms
  * executing "if [ -d /home/deployer/apps/blog/shared/cached-copy ]; then cd /home/deployer/apps/blog/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 6fb7914a0c09159399ce85f00073692c4cd32a8a && git clean -q -d -x -f; else git clone -q git@github.com:andremaha/blog.git /home/deployer/apps/blog/shared/cached-copy && cd /home/deployer/apps/blog/shared/cached-copy && git checkout -q -b deploy 6fb7914a0c09159399ce85f00073692c4cd32a8a; fi"
    servers: ["50.112.249.58"]
    [50.112.249.58] executing command
    command finished in 12628ms
    copying the cached version to /home/deployer/apps/blog/releases/20120726142915
  * executing "cp -RPp /home/deployer/apps/blog/shared/cached-copy /home/deployer/apps/blog/releases/20120726142915 && (echo 6fb7914a0c09159399ce85f00073692c4cd32a8a > /home/deployer/apps/blog/releases/20120726142915/REVISION)"
    servers: ["50.112.249.58"]
    [50.112.249.58] executing command
    command finished in 706ms
  * executing `deploy:finalize_update'
    triggering before callbacks for `deploy:finalize_update'
  * executing `deploy:assets:symlink'
  * executing "rm -rf /home/deployer/apps/blog/releases/20120726142915/public/assets &&\\\n        mkdir -p /home/deployer/apps/blog/releases/20120726142915/public &&\\\n        mkdir -p /home/deployer/apps/blog/shared/assets &&\\\n        ln -s /home/deployer/apps/blog/shared/assets /home/deployer/apps/blog/releases/20120726142915/public/assets"
    servers: ["50.112.249.58"]
    [50.112.249.58] executing command
    command finished in 693ms
  * executing `bundle:install'
  * executing "cd /home/deployer/apps/blog/releases/20120726142915 && bundle install --gemfile /home/deployer/apps/blog/releases/20120726142915/Gemfile --path /home/deployer/apps/blog/shared/bundle --deployment --quiet --without development test"
    servers: ["50.112.249.58"]
    [50.112.249.58] executing command
 ** [out :: 50.112.249.58] sh: 1:
 ** [out :: 50.112.249.58] bundle: not found
 ** [out :: 50.112.249.58] 
    command finished in 679ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/deployer/apps/blog/releases/20120726142915; true"
    servers: ["50.112.249.58"]
    [50.112.249.58] executing command
    command finished in 683ms
failed: "sh -c 'cd /home/deployer/apps/blog/releases/20120726142915 && bundle install --gemfile /home/deployer/apps/blog/releases/20120726142915/Gemfile --path /home/deployer/apps/blog/shared/bundle --deployment --quiet --without development test'" on 50.112.249.58
Avatar

Yes, I have the same problem, Rails 3.0.15, Ruby 1.9.3-p125, Rack 1.2.5