Devise custom controller Missing Template create

1.7k Views Asked by At

I have two different Devise Models on my rails app: Studios and Musicians.

I'm trying to get everything work with my custom controllers, because Musicians "has_one" adress and some other stuff. My Musicians model has the following Devise methods

:database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:confirmable, :lockable

And at devise.rb I have:

config.allow_unconfirmed_access_for = 2.days

But my main problem is with the method "after_inactive_sign_up_path_for", it seens that its never being called at all. After create I get the following:

ActionView::Missing template (missing template musicians/registrations/create,
musicians/registrations/create, devise/registrations/create, devise/create,
application/create   with --bunch of options and places where he did the search--)

But as far I studied Devise views I don`t need a create view (never needed actually)... By the way, it creates the active record, sends the email and all the stuff, the problem is just the last part :(

Here is the important part of routes.rb

devise_for :musicians, :controllers => {:registrations => 'musicians/registrations'}
#Here is the route that I want to redirect the user, it works, already tested
match 'logado', to: 'sessions#logado',  via: [:get, :post]

Here is my controllers/musicians/registrations_controller.rb

class Musicians::RegistrationsController < Devise::RegistrationsController

  def new
    @musician = Musician.new
    @adress = @musician.build_adress
    @asset = @musician.build_asset
  end

  def create
    @musician = Musician.new(params[:musician])
    @adress = @musician.build_endereco(params[:musician][:adress_attributes])
    @asset = @musician.build_asset(:photo => params[:musician][:asset])
    if @musician.save
      flash[:sucess] = "Welcome"
    else
      render 'new'
    end
  end

  def update
    super
  end

  protected
  def after_inactive_sign_up_path_for(resource)
    logado_path
  end
end 

My views are organized like this:

views
|--musicians
   |--registrations
      new.html.erb
      edit.html.erb
      _form.html.erb
   |--sessions
      new.html.erb
      _form.html.erb
 index.html.erb

I'm on Rails 4, Ruby 2 and latest Devise version, guess it is 3.2.2 - Anyone can help me ?

1

There are 1 best solutions below

0
On
....
if @musician.save
  flash[:sucess] = "Welcome" #<- i think problem here 
else
....

after save you need redirect to some path or render something
something like this

....

if @musician.save
  flash[:sucess] = "Welcome" #<- here
  return redirect_to some_path #<- path to redirect
else