my controller isn't rendering a layout

4 views
Skip to first unread message

Shawn J. Goff

unread,
Jun 3, 2010, 9:01:12 PM6/3/10
to Devise
I created a devise model. I made a controller for that model to handle
things that devise isn't handling (I'm not using :registerable, so I
need new and create, and I also need an index). None of these actions
are rendering a layout - they render the view without the layout.
Other (non-devise) controllers are rendering layouts, and the actions
that devise is handling is rendering their layouts. It is only the
actions I'm adding that are not rendering properly. What can I start
looking for?

Carlos A. da Silva

unread,
Jun 4, 2010, 12:36:29 AM6/4/10
to Devise
Are you using something from Devise in this specific controller? How
is it called?
Could you post your controller or at least the relevant parts here?
Also, is there any layout handling inside application controller that
might be affecting it?

--
Carlos Antonio

Shawn J. Goff

unread,
Jun 4, 2010, 8:32:27 AM6/4/10
to Devise
Sure. I almost posted them before but didn't want to make a mile long
post if it was going to be something simple.
The controller is as plain as can be:
Note - you'll see I started out simply (index), then I tried adding a
respond_to block on the new action to see if it made any difference,
but it didn't.

-----CONTROLLER-----

class UsersController < ActionController::Base

def index
@users = User.all
end

def new
@user = User.new
respond_to do |format|
format.html
end
end

def create
@user = User.new
if @user.save
flash[:notice] = 'Successfully created new user'
redirect_to new_user_path
else
render new_user_path
end
end

end


-----VIEW-----

%h1 Listing Users
%ul
- @users.each do |user|
%li
=user.email
%ul
%li= link_to 'Show', user
%li= link_to 'Edit', edit_user_path(user)
%li= link_to 'Delete', user, :confirm => 'Are you
sure?', :method => :delete


-----RENDERED PAGE----- (not a snippet)

<h1>Listing Users</h1>
<ul>
<li>
m...@me.com
<ul>
<li><a href="/users/1">Show</a></li>
<li><a href="/users/1/edit">Edit</a></li>
<li><a href="/users/1" data-confirm="Are you sure?" data-
method="delete" rel="nofollow">Delete</a></li>

</ul>
</li>
</ul>

On Jun 4, 12:36 am, "Carlos A. da Silva"

Carlos A. da Silva

unread,
Jun 4, 2010, 8:36:42 AM6/4/10
to Devise
Your controller is inheriting from ActionController::Base. Have you
tried inheriting from ApplicationController?
Also, try calling the :layout method in your controller passing the
name of your layout file.
As you said, the respond_to block won't help in this case.

Just for clarification, this does not seem to be a Devise related
issue.

--
Carlos Antonio

Shawn J. Goff

unread,
Jun 4, 2010, 8:45:40 AM6/4/10
to Devise
Oh, wow. How did I do that? Changing the parent class worked like
magic, of course. Pretty funny, I was going line-by-line comparing to
a regular scaffolded controller looking for what could cause the
difference - I missed the most important line!

On Jun 4, 8:36 am, "Carlos A. da Silva"
Reply all
Reply to author
Forward
0 new messages