RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

Hi, thanks for another great screencast! I only see one possible problem when using gateway.authorize&capture:

Say you checked on a valid authorize. A few days later you decide to ship the item and do a gateway.capture(...) and during those days between you did the authorize and the capture the shopping client maxed out his credit. What happens then?

Or in other words shouldn't the capture member give back another true/false upon successful completion of the actual funds just as in gateway.purchase?

I should probably read more on active merchand and find the answer myself. Would be nice if you could elaborate on that edge case where the client maxes out his cards between authorize and capture method calls.

Or is authorise(1000, ... ) able to stop the client from going below 10$ of credit when he wants to try and max out because of the dangling authorise made earlier?

Maybe this has been asked/answered a thousand times before, in which I apologize for my ignorance ;)

Avatar

Great stuff and great timing! When do you think the next episode will be up! Thank you thank you!

Avatar

@Brian, you can find my Amazon wish list here if you like. :)
http://www.amazon.com/gp/registry/wishlist/1MLM280E2D

Avatar

Another nice screencast. very useful again. Thanks Ryan

Avatar

Just a quick clarification on page caching with an 'admin' sub domain. How do you conditionally cache or not cache the pages based on the subdomain? Do you use mod_rewrite rules to pass the request through to the app for all 'admin.foo.bar' requests?

Thx.

Avatar

This is so useful to me. I have the Peepcode but seeing coding in action just works for me.

Many, many thanks for it.

Avatar

@Hubert, there wasn't a conflict with PeepCode sponsorship in the past, I just hadn't looked into Active Merchant enough back then to do an episode on it.

AFAIK PeepCode doesn't have a screencast on Active Merchant, but they do have a PDF book which I highly recommend. It's difficult to find adequate documentation on the subject.

@Jeffrey, that's a good question. I know Active Merchant itself provides two ways to handle credits. One is based on an existing transaction, and another is using a credit card number which will be treated as its own separate transaction (payment in reverse).

I'm assuming if you supply the authorization code when issuing the credit, it will treat it as a refund through PayPal but I have yet to test it.

Avatar

Great episode Ryan. One of your best!

Avatar

Activemerchant is a nice library for abstracting away the differences between Gateways.

I second the Paypal donate button increase. I've been watching these for a long time and I never noticed it before.

Avatar

When my project is ready,I will click the "PayPal Donate" here at RailsCasts =)

Avatar

Does the credit function use PayPal's "refund" operation (where fees are also refunded) or is it seen as another transaction (another set of fees)?

Avatar

Ok, this post is a little old but for those looking for a nice solution to the ActiveResource user login question you can now just use the following syntax. Clean and simple. Just like Rails.

class Pie < ActiveResource::Base
  self.site = "http://api.pie.com/"
  self.user = username
  self.password = password
end

See the Rails API for details.

Avatar

Very interesting! Much simpler than the gateway I use now. Thanks Ryan!

Avatar

Ryan,

Thank you for this great plugin, I'm using it for a project I'm working on now. But I really miss the HABTM feature. What are your plans for implementing it?

Avatar

Very, nice! I cant wait for the recurrent billing episode :)
Good job!

Avatar

@Logansbro,

I haven't used Paypal, but I did create an app using Authorize.net a little bit ago to do reoccurring billing and I wouldn't be too surprised to find out the sandbox wasn't perfectly reliable since it is just for testing. Obviously when you are dealing with money you have to be careful, and that made me really nervous. I turned my app live and tested it over a period of time with my own credit cards (and reduced amounts) to make absolutely sure. It worked perfectly and the way I expected. The only thing I hate is the fact these places all seem to nickel and dime you to death, rather than telling you what the fees (all of them I mean) will really be up front. They aren't all that large, but every time I turned around there seemed to be another one.

Avatar

has anyone else had problems with the Paypal Sandbox IPN? It never seems to work (reliably) for me. It seems like I get a ping from it about 20% of the time.

Avatar

@me : Now I can access the helper in partials. Sounds like you CAN'T use a helper (or method) similar to a model Class (or any class, I didn't test all night).
So, you can't use a method :

  def user
    @user ||= SessionUser.new(session)
  end

  helper_method :user

This will work for standard views, but not in partials (user is nil) :(

Avatar

Hi all..
How do we know where is the :lib option for gem is located? I've tried to catch it from gem documentation, i've gotten for some gems and the others aren't provide it..

Avatar

I can not get this to work all i get is a blank screen even after trying Ethan's suggestions nothing schemes to make it work

Avatar

First, I must say this tip is really interesting. Anyway, I have some problems with partials, they don't seem to be able to access the helper method, for a reason I don't know :(

Avatar

Just in case anyone runs into the issue I mentioned, if you specify a default layout, the layout will be used with a JS response. In other words, in the example, the format.js option will render the create.js.erb file, but with the HTML from the specified layout.

Seems pretty obvious now, but I assumed if the response was going to be of content-type "text/javascript", it wouldn't try to use an "html.erb" layout in any situation (since embedding javascript directly in HTML doesn't work), and just automagically render create.js.erb with no layout.

Avatar

Great tutorial, as usual!

Yes, anonymous scopes work well with will_paginate, as:

scope.paginate(:per_page => 18, :page => page, :order => 'updated_at desc')

Avatar

In the example above, what if you wanted the list to be hidden unless the search results matched your query?

I presume it would be something like

<% if some-code-here = nil %>
 <p>No results found</p>
<% else %>
  <ul>
    <% for project in @projects %>
   etc, etc., etc.

But I'm not sure. Thoughts?

I'm new and a bit rusty, I know it shows.

Avatar

The suggested code doesn't select the state from the drop-down if it's already selected for me. Not sure what I'm doing differently from the suggested code.

Adding an if statement and a few parameters to the 'new Option(name, id, false, true)' are what worked: http://gist.github.com/45324

Avatar

I couldn't get this technique to render the create.js.erb with a nested resource. Has anyone had any luck? For example, posting a form with an action like "/users/1/reviews" wasn't executing the returned JS, but posting a form with "/reviews" works fine.

In both cases, the actual controller method is invoked correctly, it's just the response that isn't working the same with a nested resource -- after looking through the code, I'm still not sure what to update.

Avatar

People interested in PayPal for Rails may want to check out the Spree[1] commerce project which has excellent PayPal support.

There's also a nice extension[2] that provides integrates support for Paypal Website Standard.

[1] http://spreehq.org
[2] http://github.com/Gregg/spree-pp-website-standard/tree/master

Avatar

To answer my question post 131, couldn't find a way to execute javascript_include_tag in a partial loaded through .rjs.

I used javascript_tag straight in the view to refresh js global variable.

Avatar

Is it possible to set keys in the hash: config.action_mailer.smtp_settings

dynamically? I'd like to set the :user_name just before an email is sent. Can that be done?

Thanks.

Avatar

Ryan, thanks for this one. This is very useful, not only for Rails developers, because the Paypal transaction processes are walked through in detail!

Avatar

I tried a lot to write a Rewrite rule, but it didn't turn out for me.. probably the hosting provider has disabled fast cgi scripts..

Instead, I installed this plugin which has even got login/logout features.. :)

http://ariejan.net/2007/08/24/super-simple-authentication-plugin-and-generator/

Avatar

when I use this method on localhost, everything works fine.. but, when I host it online, the application root directory is in domain.com/local ..

in this, the authentication window comes, but it doesn't authenticate me actually.. I type the login, password, still, the window appears again and again, and if I cancel, I get:

HTTP Basic: Access denied.

The rewrite rule pointed out by Joshua even didn't work!

Avatar

Thank's a lot Ryan for covering this.

I've been waiting for a time when I'll use subdomain. And this happened today.
Without this episode ...it's sad to imagine.

Thanks!

Avatar

If the PaymentNotification.create method shall be secure you rely on a ssl/https-connection, right? Or is there another secure way where I don't have the https-overhead for my webserver? Or did I missed something?

Avatar

@Edgar
thanks to Ryan, soon they will know Rails better then we are
<B-)

Avatar

Great videos, Ryan! Keep up the great work!

After following this tutorial I'm having trouble to convince open id to send me "required" fields specified authenticate_with_open_id.

The result from registration is just something like this: registration = #<OpenID::SReg::Response:0xb6841870 @ns_uri="http://openid.net/extensions/sreg/1.1", @data={}, @ns_alias="sreg">

Please help!

Avatar

Dear Ryan, thanks a lot for your work it is really amazing.

I am still trying to digest all the information on this number.

The first question I have, maybe it is a very stupid question, is how I should management all this secret information on a project that suppose to be open-source?

The repository will be very uncompleted with all these file-keys, secrets, and private information.

The deployment will be not as simple as an a normal project.

Maybe it will be just as the database.yml .. I don't know maybe I just thinking on loud.

Thanks again for your job :)

f.

Avatar

Ryan,

Thanks for the great series! It has really helped me to understand Paypal processing much better.

Following your screen cast this morning, I run into a Paypal error that reads "There was a problem with the decryption of your secure order. Please contact your merchant."

The form looks right and I followed your command line entries to the letter. Is there an OpenSSL dependency that's not included in Rails or a certain version requirement? Also, do you know of a way to further debug errors in Paypal?

Thanks again for your great screencasts!

Bryce

Avatar

Thanks for this very helpful Railscast.

Anyone availing of a paypal subscription instead of a cart should make sure to have a hidden form 'cmd' field with value of '_s-xclick', and an encrypted 'cmd' field with value '_xclick-subscriptions'.

Othewise you'll face the dreaded "We cannot process this transaction because there is a problem with the PayPal email address supplied by the seller."

See this thread for help: http://www.pdncommunity.com/pdn/board/message?board.id=ewp&thread.id=1033

Steve Q

Avatar

Any Idea how to include javascript file from a partial loaded via rjs ?

Thanks !

Avatar

I agree with guys above. I wouldn't have started programming in rails if it wasn't for your video casts and your help in forums.

This is really great Ryan. I am also waiting for Merchant railscasts as well.

Thanks you very much!

Avatar

It looks difficult,
anyway thanks,
and waiting for Merchant railscast!

Avatar

Awesome mate... can't wait for the Merchant stuff and hopefully how to manage recurring payments?? please! maybe even automatic invoicing? awww gone to far!

Avatar

Amen to that. Thanks Ryan. Following you since the start.

Avatar

I don't know what the Rails community would be without you, Ryan. Ughf, what a scary thought..

Avatar

Thanks, Using it for current project.

It doesn't work with HABTM.

Avatar

Hi, Ryan

  you mention at the top that you tried to use class_inheritable_accessor, but it did not work.

An accessor is indeed a lot better rather than a class variable (for several reasons); but here we can just use cattr_accessor (as we don't need to deal with different values in the Inheritance tree).

It worked, simplifying things significantly (code is cut in half): http://pastie.org/352681

I started watching all your screencasts (from the first one): a terrific way to see Rails from all angles!

Avatar

Actually the params ARE being passed to the ‘Users’ ‘new’ action, but apparently the authenticaton is failing somewhere.