RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

I was getting an error and the emails weren't being sent when I was submitting the form after filling in my email address. I had to make a change to this code below:


def password_reset(user)
@user = user
mail :to => user.email, :subject => "Password Reset"
end

I had to change

user.email

to

@user.email

Avatar

Thanks for the link! That cleared it up for me.

Avatar

To use the proper settings. Maybe rake command starts the wrong version of ruby. Maybe it sets up a wrong configuration... it is written nicely already: http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/

Sure, you don't have to use bundle exec. In this case, however, you have to use binstubs, and you have to run commands from there.

Avatar

You need to do "bundle exec" especially when doing rake tasks

Avatar

Stellar episode, Ryan!
I would love to see a Part 2 on cancellation and insufficient funds with test cases, hard to find relevant practical examples to learn from.

Keep up the great work!

Avatar

I just wanted to ask the same question. I just set up a vagrant box as shown in this episode but I installed rvm and I don't need this bundle exec to run the server.

Avatar

Never mine. I was doing it wrong. It works fine.

Avatar

Fantastic video, as usual.

Barely related question: Why the need for adding "bundle exec" to "rails s"? I think I somehow glossed over the "bundle exec" movement as I see it everywhere now, but don't fully understand why.

From what I just read it executes the command in the context of the bundle, but I've never needed to do this in the past (or rather, I never knew I needed to :-) Is this related the use of rbenv and lack of gemsets?

Avatar

If the form doesn't pass validation, the tokens are lost and have to be entered again. What would be a clean way to have it keep the tokens on validation errors.

I don't like the way I'm doing it now:

ruby
def create
  @book = Book.new(params[:book])
  params[:author_tokens].split(',').each do |author|
    @book.authors << Author.find(author)
  end
  ...
end
Avatar

Does Passenger support http streaming in Rails3.1 ??

Avatar

At first I was afraid that the free episodes' quality might suffer from the pro and revisited episodes. That is definitely not the case, I am, well, impressed. Thx for all these efforts.

Avatar

Take a look at this article. It's really easy. You'll need a reverse proxy and that's pretty much it

http://blog.phusion.nl/2010/09/21/phusion-passenger-running-multiple-ruby-versions/

Avatar

AMAZING! Loved it. Will definitely use soon.

install nodejs as easy as:
much faster than therubyracer

bash
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
Avatar

Nice railscast, I can't wait to see it with capistrano.

It would be interesting to show us how to setup and run multiple apps with different version of ruby and rails with this.

Thank you!

Avatar

The ActiveRecord association User-Appointment is wrapped by a decorator through UserDecorator#appointment mentioned above, so you get a AppointmentDecorator when calling @user.appointment

Avatar

Yeah! read that on twitter too. Go to bed next time you get sick, we can wait. Hope you feel better.

Avatar

Hey Ryan B, read on #railscasts that you had the flu. Thanks for your Railscasts despite your being sick!

These deployment related screencasts are great! Keep them coming!

Avatar

Thanks! Great episode. I would really like to know more about the benefits of unicorn over passenger. I've found some info in the comments on the github unicorn site.

Matt Freels says
Unicorn can restart your app without any lost requests or stalls.
Passenger drops your app and its workers, and then lets the next request bring the new version up.

I would say the biggest difference is that where Passenger is opinionated and fairly all-or-nothing, Unicorn gives you more transparency and control over its configuration (while still nicely managing workers).

Question is where is passenger ok to use? It seems easier to set up? (or is it?)

Avatar

The latest version of Nginx on Ubuntu

add-apt-repository ppa:nginx/stable
apt-get update
apt-get install nginx

If the add-apt-repository ppa is not found install:
apt-get install python-software-properties

Avatar

I used Virtual box to set up a staging environment on my dev machine and I used port forwarding on my router to connect the incoming requests to the virtual machine's internal IP address. So to access the staging server from the web I used something like www.my.web.address:1234. This work fine except with PayPal IPN. Paypal IPN does not like to send IPNs to non-standard ports. I am already using Port 80 for another VM so that's not an option.

Anyone know how to fix this?

I resolved this by getting a mico-instance on Amazon, then everything worked, but I would really prefer to do it locally if possible.

Vagrant has some really nice features - thanks for the tutorial.

Avatar

Thanks for this great tutorial! But, isn't it easier and more efficient to use rvm instead of rbenv?

Avatar

Hi, folks!

I'm having some issues here. I have Rails 3.1 and followed all the initial steps correctly.

The problem is that my "ul" list does not become "sortable". It does not work.

Here is my code:

drafts.js.coffee
jQuery ->
  $('#sortable').sortable()
_form.html.erb
# This partial is called by new and edit views from drafts_controller.rb

<ul id='sortable'>
<% @draft.clauses.each do |clause| %>
  <%= content_tag_for :li, clause do %>
    <%= link_to h(clause.name), clause_path(clause) %>
  <% end %>


<% end %>
</ul>

Thanks in advance!

Avatar

yes, I'm actually using Vagrant, so "config.ssh.max_tries = 150" can be helpful sometimes

Avatar

This bug is a #1 priority to fix, if I can get a hold of what is causing it. Unfortunately, finding the exact cause has been difficult. :(

Avatar

Thanks for the screencast! This was a fantastic introduction to Vagrant. Some suggestions for next things to look into on Vagrant after this screencast:

  • Instead of manually using shell commands to setup your environment, but also to avoid the complexities of Chef, check out the Shell provisioner. You just pass it a shell script on your local machine, and it runs it on the remote machine.

  • Host-only networking is very useful, as it allows you to set a static IP on your machine. Rather than forwarding each port you need, you can access any port (assuming you have no firewalls on the machine). Also, you can use something like Ghost to assign hostnames to the VM.

  • For Rails especially, NFS shared folders become very important, since there is a bug in Virtualbox which causes performance to degrade with many files in the shared folder. NFS avoid this issue.

Thanks again Ryan! I'm a big fan of RailsCasts and a happy previous viewer (I no longer do much rails dev :().

Avatar

Virtualbox has some bugs with SSH dhclient to get a proper IP address (https://github.com/mitchellh/vagrant/issues/455)

anyway, Vagrant is a pretty good interface to build distributed local environment and to provide production mirror servers setup

Avatar

This is awesome, I didn't realize that something like Vagrant even existed. The most painful part of development for me has been getting other developer machines up and running. Can't wait to try this out, thanks for covering this :)

Avatar

I've been using Vagrant since it's very beginning. Helped it's author test the early versions and contributed to it's underlining 'virtualbox' gem. A brilliant tool! Thanks for making making a screencast about it.

Personally I setup the environment and repackage it rather than using Chef (because Chef can take a while depending on your internet connection).

Also, you can create custom plugins to help you save time. Things like 'vagrant rails_server', which could load up the box, start up all background servers, and load the rails application server, all in one command. It will speed up development.

Avatar

Hey Ryan! Thanks again for all you do...love your screencast! I tried to set my production.rb file to deliver the email, but it is not working...

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "myserver",
:user_name => "fritz.rodriguez.jr",
:password => "password",
:authentication => "plain",
:enable_starttls_auto => true }

config.middleware.use ExceptionNotifier,
:sender_address => 'fritz.rodriguez.jr@gmail.com',
:exception_recpients => 'fritz.rodriguez.jr@gmail.com'

Any ideas? Thanks!

Avatar

Hi everyone, can somebody take a look in this question:

http://stackoverflow.com/questions/7882084/while-polling-server-how-to-update-the-content-of-a-lightbox-using-rails-3

I'm trying to update a lightbox, instead of the normal view.

thanks

Avatar

if $('#card_number').length

was always returning 1 for me, even if there were no values in the input.

So I used

if $('#card_number').val().length > 0

and that worked.

Avatar

I am missing the iTunes announcement for this podcast?
Will it comes soon?

Avatar

Can anyone expand here on why using a before create callback is a bad idea? In looking at the Stripe monospace-rails example app, it handles a user updating their card quite nicely, which wasn't covered in this episode. However, a before_save call is how they're handling it.

Awesome episode, I'm so grateful for this intro into Stripe

Thanks,

Avatar

Note to newbs, if you experience undefined method errors. Restart your server

Avatar

it's like they said, i've been working with this gem and one advice, if you have to customize too much your admin don't use this gem, it depends on formtastic and metasearch, which gives a lot of work to understand how works and make simple things in rails very complicated.
use just for simple projects.

Avatar

While playing with the console I found that when i do Article.order("name") i do not get a list ActiveRecord::Relation objects(as shown in the screencast). You spoke about lazy-loading.. starting a business in cyprus

Avatar

@ryan : Seems there is something wrong with the (reply/edit/delete) buttons, refreshing the page seems to fix it.

Avatar

This might be a better solution anyway:

{
:get => "http://sub.test.host/invitations/new"
}.should route_to(:controller => "invitations", :action => "new")

{
:get => "http://test.host/invitations/new"
}.should_not be_routable

Avatar

I just tried to replace the subdomain condition (before_filter)
with a routing contraint.

Unfortunately my controller specs fail. I had specs in place
that check that I get 404 when accessing certain actions
without a subdomain.

Having a look I can see that the contraint class is never called.
Seems the specs just ignore the contraint for some reason.

Works perfectly when I try it manually.

Avatar

This took me a while to figure out as well. You want to add the session line to your users controller and point it wherever you are taking your users once they log in.

ruby
  def create
    @user = User.new(params[:user])
    if @user.save
      session[:user_id] = @user.id
      redirect_to some_path, :notice => "Signed up!"
    else
      render "new"
    end
  end
Avatar

I tried to add the cookie line because I would like to automatically log in after signup as well but I am getting the error:

NoMethodError in UsersController#create

undefined method `auth_token' for #< User:0x9a89d60 >

Am I missing something?

Avatar

For those who aren't using CoffeeScript, here is the compiled subscriptions.js file: https://gist.github.com/1307748

Great episode, btw. I'm loving Stripe so far.

Avatar

Is there a way to use acitivemerchant's PayPal Payments Standard functionality, without specifying credit card information? I want the user to enter their credit card info on PayPal's site, not mine. Express Checkout use to let users pay with credit cards, but no longer allows it. I've looked at activemerchant's source code and it expects either a credit_card hash or a billing agreement ID, but maybe there is some way to fake it out so that PayPal will ask for the credit card info?

Thanks

Avatar

There used to be a gem that put this into the DB and had an interface , why has everyone move way from that? is there something wrong with that approach?

Avatar

As far as i know, Soap4r and ActionWebService are the only SOAP server libraries.