RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

Great episode!

I had to modify the rake autocompletion a bit to suppress an error "No such file or directory .rake_tasks~" in a directory that didn't contain .rake_tasks~ already.

Just directed standard error to /dev/zero (or it would be /dev/null if you are on a linux box)
http://pastie.org/3041568

Avatar

I worry that approaching zsh like this will be like approaching vim via Janus. When I was a Janus user I couldn't tell you what was a feature of Janus' configuration or plugins and what was a native feature of vim. It wasn't until I started my own vim configuration from scratch that I really started to understand what was going on.

Avatar

I'm already using the dotfiles from ryans github site. Is it worth for me to switch to using this and have to move all my custom stuff?

Avatar

Hi Ryan.

Regarding to your c() _c() example, you can do the same thing just doing :

cdpath=(. ~/Railscasts)

It adds given paths to current directory path so all files and directories in ~/Railscasts are available from anywhere just typing : cd some_dir_in_railscasts_dir

That's a native future of ZSH so why bother reimplementing it.

Avatar

I'm closing in on it. rvm seems to forget which ruby to use.

"rvm system ruby-1.9.2-p290" is a small fix even though it does not fix this entirely...

Avatar

I'm getting the same error, don't know how to fix it.

Avatar

Yippi! It just crashed my environment... I'm using rvm if that makes a difference:

bundle
/Users/kai/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst minitest-1.6.0, rake-0.8.7, rdoc-2.5.8

Any Ideas?

Avatar

Couldn't agree more - love the thought that's gone into the fallback. Will be on my current project soon! :)

Avatar

There is a good post on how to use this with Cucumber:

http://pivotallabs.com/users/mgehard/blog/articles/1595-testing-omniauth-based-login-via-cucumber

It made me think though (which is never good),
is it not possible to log in as any user simply
by providing the correct provider and uid.

Avatar

9$ is best for one month for me.. :) I assume that the price will be same in 10 years ;) But you should also denote Ryan for 50$.

Avatar

Excellent episode Ryan, I really love the fallback functionality remaining intact. Definitely going to use this.

Avatar

To adapt the magic sauce with nested resources :

ruby
def find_commentable
  params.each do |name, value|
    if name =~ /(.+)_id$/
      return $1.classify.constantize.find(value)
    end
  end
  nil
end

i did :

ruby
def find_commentable
    params.each_with_index do |elem, index|
        if index == params.length - 1
            if elem[0].to_s =~ /(.+)_id$/
               return $1.classify.constantize.find(elem[1])
             end
        end
    end
  end

which allow to find the last controller param with its Id , and for me works well to get the @commentable type and id

Hope it helps someone, cheers

Avatar

Railscast is the best $9 I spend every month. I would love to pay $50 and get one episode each weekday.

Avatar

I bought a pro subscription just for this episode, and I'm not at all disappointed. A huge PLEASE for Paypal cancellation episodes!!

Avatar

My ugly, and hopefully temporary, fix:

Mercury.PageEditor.prototype.save = function() {
var url = Mercury.saveURL ? Mercury.saveURL : this.iframeSrc();
var data = this.serialize();
Mercury.log('saving', data);
if(this.options.saveStyle != 'form') data = jQuery.toJSON(data);
var method = (this.options.saveMethod == 'PUT') ? 'PUT' : 'POST';
jQuery.ajax(url, {
type: method,
dataType: this.options.saveDataType || 'json',
data: {_method: method, content: data},
success: function() {
Mercury.changes = false;
Mercury.trigger('saved');
},
error: function() {
alert("Mercury was unable to save to url:\n"+url);
}
});
};

The missing line was:
Mercury.trigger('saved');

Avatar

+1 Definitely looking forward to the Capistrano deployment episode.

Avatar

Same here... this is driving me crazy! I've tried everything I can think of to get the access to saved event... nothing is working.

Avatar

After running gem install vagrant, I attempted to add a box, but it can't find vagrant?

$> vagrant box add lucid64 http://files.vagrantup.com/lucid64.box
-bash: vagrant: command not found

Anyone else run in to this?

Avatar

Nice an neat except for this trick with multiple scroll events being triggered. I think it would be much cleaner to unbind the scroll event till we get the results and once more products are loaded, bind it again.

Avatar

I got the same error message if I try to authorize before I've signed into Devise. However, if I sign in through Devise and then try to authorize, it works, although that seems pretty pointless to require someone to authorize first through devise

Avatar

Interesting, i was appending a class instead on an id and that was causing the problem. I didn't think this mattered at all. Strange.

Avatar

I tried this for some reason. my index.js.erb is not being listened to but i see it on my terminal " Processing by BusinessesController#index as HTML" .

All the products (businesses) are being loaded at once. I am not sure what i'm missing, any ideas?

Avatar

Nice revision. In fact, I am creating a web app for my company (unbeknownst to them) that connects to a legacy DB and one of our tables has hundreds of rows. This is going to look good on that page!

I am so glad I signed up for your Railscasts. Keep them coming!

Avatar

I'm having this exact same issue, any solution yet?

Avatar

Great screencast as usual, wondering though the following:

1) This is similar to the approach you showed in the sharing mustache templates screencast, wondering given that it essentially achieves the same objective when you would choose to use this simpler jquery approach vs using mustache template, ie what are the pros and cons of each.

2) any hints how one can test endless scrolling in rspec/capybara integration tests, specifically, any ideas as to how you would simulate a scroll near the bottom in capybara?

Avatar

Anyone know how efficient updating the sort order like this is? In the case of my application, users have hundreds of items in a list. If I have thousands of users are all changing the sort order like this on lists of hundreds or possibly thousands of items, it seems the efficiency would be bad.

What are some other thoughts on this?

Avatar

For anyone struggling to get this going with Test::Unit, you can check out my simple setup here: http://railsgotchas.wordpress.com/2011/12/16/testing-with-spork-guard-and-testunit/

Avatar

Is it possible to use nested forms with a serialized Array attribute?

http://stackoverflow.com/questions/8537588/nested-form-with-embedded-attributes

Can't get it to work.

Avatar

This still doesn't work when you have cucumber backgrounds as the around hook gets executed after (!) the background is executed.

Avatar

This is a great start. However, it doesn't work with Scenario Outlines. The following does however:

ruby
Around('@vcr') do |scenario, block|
  s_name = scenario.name.underscore.gsub(/[^\w]+/, "_").gsub(/^_/,'').gsub(/_$/,'')
  if scenario.respond_to? :scenario_outline
    feature = scenario.scenario_outline.feature
  else
    feature = scenario.feature
  end
  f_name = feature.name.underscore.gsub(/[^\w\/]+/, "_")
  VCR.use_cassette("/#{f_name}/#{s_name}", record: :once) { block.call }
end
Avatar

Maybe too late, but i want to ask a question about my error. When i upgrade my application from 3.0.11 to 3.1.3 there is no problem.

But, i have to use double mysql server one of them is legacy database with version 4.0.

When i trying to connect this database, i got an error like that;

Mysql::Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE Key_name = 'PRIMARY'' at line 1: SHOW INDEX FROM personel_giriscikis WHERE Key_name = 'PRIMARY'
ActiveRecord::StatementInvalid: Mysql::Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE Key_name = 'PRIMARY'' at line 1: SHOW INDEX FROM personel_giriscikis WHERE Key_name = 'PRIMARY'

But, in rails 3.0.11 there is no problem and i was making the query in the Mysql 4.0.

Any Idea, thank you.

Avatar

Got it. Need to provide a paginate method on each searchable Class.
Thanks for the tip (@Karel) and for the great screencasts (@Ryan).

Avatar

@Imbacelar: Search for "kaminari" in issues at Github, there are plenty of examples which will get you started.

Avatar

I've updated the Ip to be set for production, but the messages are not being transmitted. There is no problem with the connection as well as there is no error found when trying to do the message post in firebug. Can you guys suggest how I debug whats going on wrong?

Avatar

I've updated the Ip to be set for production, but the messages are not being transmitted. There is no problem with the connection as well as there is no error found when trying to do the message post in firebug. Can you guys suggest how I debug whats going on wrong?

Avatar

Thanks for this great video. I published my first gem after watching this video.

https://github.com/hisea/mobile_rails

Avatar

Got it.

ruby
def name
   h.best_in_place_if is_dashboard?, model, :name, nil: 'Click to add a name.'
end
Avatar

Is it possible to use best_in_place with decorators (e.g. Draper)? If so, how?

Avatar

Did it work for you? For me it doesn't and it also broke the sort

Avatar

Did it work for you? For me it doesn't and it also broke the sort

Avatar

I've having a problem with this too - did you ever solve this?

Avatar

I think the test_should_have_zero_for_weight_when_not_shipping test is very weak. weight will return zero simply because there are no line items, with no weights. If you had line_item.build_delivery_method(:shipping => true) instead, the result would still be zero.

Avatar

I am having problems in re-indexing a model, since I am using kaminari instead of will_paginate.
The pagination method for Kaminari is "page" instead of "paginate".
Can I set this up anywhere on the Tire gem or do I have to define a paginate method on each searchable models, that point to the page method?
Thanks

Avatar

How would you change/add to this script, if you wanted to get the respective cities of each state?

Avatar

@amzwebcreations, that would be really, really nice