Rails 3 render part from another controller (error: ActionView :: MissingTemplate)

I am trying to include a login (username / password) in the header of my application .html.erb. I get this error:

Missing partial /login with {:handlers=>[:rjs, :builder, :rhtml, :erb, :rxml], :locale=>[:en, :en], :formats=>[:html]} in view paths "/app/views"

This happens when I make this call in my application.html.erb application:

<%= render '/login' %>

'/ login' is defined on my .rb routes as:

match '/login' => "sessions#new", :as => "login" 

UPDATE: here is my session controller:

class SessionsController < ApplicationController

  def create 
    if user = User.authenticate(params[:email], params[:password])
        session[:user_id] = user.id
        user.last_login = Time.now
        user.save
        redirect_to root_path, :notice => "login successful"
      else 
        flash.now[:alert] = "invalid login / password combination " # don't show pass + params[:password]
        #render :action => "new"
        redirect_to login_path, :notice => "wrong user pass"
      end
  end

  def destroy 
    reset_session
      redirect_to root_path, :notice => "successfully logged out"
  end

end

I saw in other posts that this may be due to the fact that it does not define the variable in the controller action, but since it is a session and it is in application.html.erb (application_controller.rb), I am not sure how to do this . Does anyone know how to do this? Thank!

+5
source share
2 answers

<%= render "sessions/login", :@user => User.new %>

, , .. "_login.html.erb", / @user , :

form_for @user, :url => sessions_path do |f| 
  f.text_field :email
+9

case rhtml, html.erb.

.

:

rhtml rails <= 3.0.10. 3.1.12. , .

0

All Articles