Devise routes /:param not working

Posted by Jacob Schatz on Stack Overflow See other posts from Stack Overflow or by Jacob Schatz
Published on 2012-06-10T16:36:03Z Indexed on 2012/06/10 16:39 UTC
Read the original article Hit count: 339

Using devise 2.1.0
I am trying to send the new registration page a PricingPlan model.
So in my routes I have:

devise_scope :user do
    delete "/logout" => "devise/sessions#destroy"
    get "/login" => "devise/sessions#new"
    get "/signup/:plan" => "devise/registrations#new"
  end

And I override the devise registration controller. With this in my routes.rb to make it work:

devise_for :users, :controllers => {:registrations => "registrations"}

In my actual Registration controller which overrides Devise's controller I have:

class RegistrationsController < Devise::RegistrationsController
  view_paths = "app/views/devise"
  def new
    super
    @plan = PricingPlan.find_by_name(params[:plan])
  end

So that the default views still go to devise....
In my new view for the registration controller I call this:

<h3>You've chosen the <%= @plan.name %> plan.</h3>

And I get this error:

undefined method `name' for nil:NilClass

Also... in my PricingPlan model:

class PricingPlan < ActiveRecord::Base
  has_many :users

And in my User model:

class User < ActiveRecord::Base
  belongs_to :pricing_plan

I'm rather new at rails.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about activerecord