RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

This is great...I was just looking into a db schema for the other side of your nested model example (where results would be saved and the user would have a chance to edit the results.) HSTORE seems like it would be a good way to store all the survey responses.

I was going to serialize all the question responses and store them in a column of a table named survey_responses but it looks like HSTORE is a more robust solution!

Avatar

Awesome ! but, anyone can tell if queue_classic load the whole application in the workers ? I'm running on a small VPS and it's hard to have 80mb of RAM used by background job workers... just for send registration email (like DJ)

Avatar

Another thing to keep in mind: Postgres supports functional indexes, i.e index over the output of any arbitrary expression. This means that you can even use indexes when sorting over HSTORE values if you build the right index.

HSTOREs are really powerful tools.

I do hope though, that one day we will get the same versatility in a native JSON column and I think we are on the right track as 9.2 will already have a native JSON type albeit with no functionality aside of validation, but that's up to extension writers to fix.

Avatar

Hello, i have questions about multi rails apps with unicorn. If we want to add two or more rails application with unicorn in nginx, how can we create the multi-unicorn-process startup/shutdown script?

I googled more of them somebody prefered god gem but i couldnt find proper solution for this.

Can you have any idea?

Avatar

So, the only advantage of QC over DJ is that in uses some internal postgres hooks and doesn't hit database every n seconds like DJ, right?

In that case DJ is still far more advanced and feature-rich and i see no reasons considering QC over it.

Avatar

Nice to see how to implement Hstore in rails views. Thanks Ryan.

Avatar

Nice introduction to QC - thanks heaps. What's with that video poster though? ;-)

I'm definitely considering the jump to Postgres, it would be really nice if there was a PG engine for Faye.

Avatar

Is it possible only to push certain tables when using TAPS. I´m using a MYSQL DB in development, and need to transfer my users table and images table to production, which uses Postgresql.... Any suggestions?

Oh, my production database is on Heroku by the way

Avatar

Is it possible only to push certain tables when using TAPS. I´m using a MYSQL DB in development, and need to transfer my users table and images table to production, which uses Postgresql.... Any suggestions?

Avatar

Hi kmoczydlowski,

I used ipn_url and tested with Link

But there's still one issue:

I update Ryan's methodology with the following:

ruby
process :create_recurring_profile, period: :monthly, frequency: 1, start_at: Time.zone.now, ipn_url: payment_notifications_url
  • But PayPal does not call back my "ipn_url".
    I checked and saw the transaction was completed. I can see the transaction ID by printing the "reponse" value on console

  • By the way, I don't know whether PayPal will call my "ipn_url" in the next month recurring billing.

Avatar

What if you wanted to put a validation on Question to ensure that it's not blank... or maybe validate its uniqueness against all of the other Questions to ensure none of the names are the same?

The validations are easy, but the hard part is correlating those Rails errors to which Question input actually failed in the case of multiple children errors. If you had several questions that each were non-unique or perhaps blank, Rails will simply merge all of those errors into one key, and you have no way of associating those out independently from one another.

Does anyone know a workaround on this problem?

Avatar

Are you looking for ipn_url, not notify_url?

Avatar

I am using Sublime Text 2 beta (because I use Ubuntu). Any ideas if Sublime Text 2 has a color wheel / palette like Ryan got to work in Textmate?

Also, I was kind of looking for some help on configuring and browsing though a list of snippets that Ryan uses for Textmate. Anyone know anything about that? I'm a bit tired of typing <%= %> and I'm not sure I want to switch to haml.

Thanks

Avatar

True, I needed also to chown ubuntu /var/chef in order for it to work

Avatar

I'm seeing:

AbstractController::DoubleRenderError (Render and/or redirect were called multiple 
times in this action. Please note that you may only call render OR redirect, and at most 
once per action. Also note that neither redirect nor render terminate execution of the 
action, so if you want to exit an action after redirecting, you need to do something like
 "redirect_to(...) and return".):

  app/controllers/posts_controller.rb:39:in `show' 
Avatar

Probably not any difference- but SEO isn't everything. If you're reading off a URL to a person, saying "one dash my..." doesn't make much sense.

Avatar

What was the other thing? I'm having the same issue.

Avatar

Same thing happened to me when watching this and Episode #343.

Avatar

Under the validate_card method you'll have to change:

ruby
errors.add_to_base message

to

ruby
errors.add :base, message
Avatar

Hi Aldo,

sorry for the late reply, just found out about your posting.
We haven't planned support for globalize3 yet, but it definitely seems interesting.

We will have a look at it soon. Have you already had a chance to try phrase?

Avatar

Thank you Jacob. That works until I tried to save, I will still get the 'unable to save to the url' error.

I followed the instructions accordingly but no luck.
Would you know the likely reason why this happen?

Avatar

Hi,

I'm doing a project in rails & mongoDB ... how can I make this searching work with mongoDB ? I'm using mongoid as mapper.

When I'm searching it is giving me this error :

undefined method `expand_complex_criteria' for ["name LIKE ?", "%fd%"]:Array

Avatar

Love the PG Text Search links. Very useful~!

Avatar

Hi Ryan,

I want Paypal recurring payment to notify with option notify_url, but gem "paypal-recurring" returns the following error:

undefined method `notify_url=' for #PayPal::Recurring::Base:0x131651bc

I do this at action "create_recurring_profile". Here is the content of the options:

ruby
options == {:
token=>"EC-50M34370CB595383G", 
:payer_id=>"H3N8YE7V4LLYQ", 
:description=>"Description for payment plan 10", 
:amount=>10.0, 
:currency=>"USD", 
:period=>:monthly, 
:frequency=>1, 
:start_at=>Mon, 23 Apr 2012 02:36:04 UTC +00:00, :notify_url=>"http://localhost:3000/payment_notifications"
}
Avatar

Hi Ryan,

Is there any way to use paypal notification in combine with PayPal Recurring Payment?

Thanks,
Dat

Avatar

I'm getting in this episode the same strange thing some other user mentioned in another thread. It seems it's cut off in the end, interrupting Ryan mid-sentence... Probably just a few seconds of video cut off but I think it's worth mentioning.

Great episode as always.

Avatar

Hi,

thanks for this great cast. I wrote a small engine with two controllers and now I want to integrate this controllers into the devise based security infrastructure. In my app controllers I'm using a before_filter :backend_rights_required. How can I add this filter to my engine controllers as well from the main app without changing the engine as self?

Thanks a lot
Dirk

Avatar

Alexander

I will respectfully challenge you on this one. Ryan's timing is absolutely uncanny! I've been agonizing over how to get rid of elastic search as I move my app to heroku which has only beta support via Bonsai.io for last week.

It also happened to be my Birthday on the 17th so the timing is especially auspicious!

Thank you Ryan for these amazing screencasts. When someone finally creates the RoR Hall of Fame, you will surely be one of the top nominees!

Avatar

Thanks for the nice documentation. Now there is nothing in the way to have an easy start with will_filter :)

Avatar

thanks a lot (+1)

That was the last piece of my puzzle!
Now everything is running properly!

I am so proud!
Thanks Ryan & Paul

Avatar

So far the best GUI for pg i've used is Navicat Premium ... and by "best" i mean... Not as bad as the worst lol

Wish Sequel Pro supported pg! :)

Avatar

Hey Ryan. Thank you for this great tutorial!

I stumbled into one problem where rake db:migrate:all fails, because of a missing port configuration for the test environment. I documented the problem and the solution on Stackoverflow.

One more question: Would you recommend to prepend bundle exec to the commands you used?

Avatar

As per their online documentation - Rails 3.2 is not yet supported with version 1.0 - but should be with the next minor release.

Even after installing Rails 3.1.4 I couldn't get the stable version to work. I love everything about rails - except issues that I seem to have regarding versions and dependencies. :( I use rvm - and that seems to be a nightmare when it doesn't work.

Avatar

Any chance of getting this series updated for the Rails 3.x series of frameworks?

I'm having some difficulty translating the routes file in particular. Has anyone used this recently? How did you modify the current_cart line?

I'm trying to build a very simple store for a friend. He is selling one product - and it is a customizable product (different shapes, sizes, and art styles) - but really just one product. So - it didn't make sense for me to use one of the larger e-commerce packages.

It is also nice to know how to roll your own. :) I hope this is updated.

Ken

Avatar

If you use a random filename for your photos, recreate_versions! won't save them to the model properly. See this: https://github.com/jnicklas/carrierwave/wiki/How-to%3A-Create-random-and-unique-filenames-for-all-versioned-files (specifically search for "recreate")

Avatar

I'm running into a problem after I try to run the initdb /user/local/var/postgres command. It says:

creating directory /user/local/var/postgres ... initdb: could not create directory "/user": Permission denied

I've tried Googling it, but no luck. Any ideas?

Avatar

Any reason not to use your nested_form gem anymore?

Avatar

I second this. I'm getting this exact same error running rails 3.21 and Ruby 1.9.2.

Brilliant screencast, BTW, Ryan. Extremely helpful stuff.

Avatar

Happening for me in Chrome (both Lion and Snow Leopard). Switching to html5 seems to resolve the problem.

Avatar

What is the way to test beyond login_required?

Trying this in spec/requests does not seem to help:

before do
  @user = FactoryGirl.create :user
  cookies[:auth_token] = @user.auth_token
  visit "/"
end

Results in a redirect to the signin page. Can anybody help with this?

Avatar

There is an option within the facebook app admin screen, called authenticated referrals. So when a friend clicks a link posted on facebook by your app, they will be asked to allow access to the app before proceeding.

I am curious what the best way would be to basically do all the steps in this episode, authenticate, register, login, etc..but during this action:

The url that is passed into the app from authenticated users looks something like this:

www.app.com/?code=##

which returns the code upon authentication.

How can I take that code, and basically do everything needed to get the omniauth hash...this doesn't seem to work:

request.env["omniauth.auth"]

Is there something special that oauth is doing in the callback URL that can't be done in other controller/actions?

Thanks.

Avatar

What is the difference between Cocoon and awesome_nested_fields?

Avatar

small typo in transcription (ASCIIcast)

/app/sweepers/products_sweeper.rb

should be singular

/app/sweepers/product_sweeper.rb

Avatar

Do you think this solution could handle a system with a single model but millions (around 4M) of records?

Avatar

Does anyone know how you would make the questions answerable (perhaps assuming that you were using Devise for user authentication and had access to current_user)? I'm guessing that you would have a model that stored the ID from a User model as well as an ID from the Answer model. So then on the show page, each answer that was listed would be a link that would allow the user to answer the question.

So i guess my question is: What code would you use to then save this into the database when the user clicked the link?

Also, is this the best way to go about this? should this actually use a form instead? It seems like an easy thing to do but I'm not sure of what the Rails way to approach it is. Thanks!

Avatar

Thanks Omar.

Just a quick note to say I asked the author of postgresguide.com if he could post some tips on backing up and restoring, and he promptly published the following page!

http://postgresguide.com/tips/backup-restore.html

I think with that info and Ryan's screencast... I am ready to give PG a go :D

Avatar

I was wrong, above. Even with pg_search, I run into problems with the ActiveRecord-generated queries. e.g.:

https://github.com/Casecommons/pg_search/issues/14

From trolling the web, it looks like the problem in ActiveRecord won't actually be fixed until Rails 4.0.