Ruby on Rails Friday, January 27, 2012

It didn't work, when I do


devise_for :users do
    root :to => "devise/sessions#new"
end

because I want to log in in the root url and then remain there, but with a different rendering (logic is inside the new view of users/sessions)

It keeps trying to redirect to the root url again and again, giving a message "Too many redirects occur..."

What should I do?

Thanks in advance


On Thu, Jan 26, 2012 at 1:09 PM, Walter Lee Davis <waltd@wdstudio.com> wrote:
I just did this. I let Devise generate the views (rake task, check the wiki) and then I modified the devise/sessions/new layout to combine sign in and sign up.

<%- title "Sign in or sign up" %>

<div class="left half">
       <h3>Already registered?</h3>
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
 <p><%= f.label :email %><br />
 <%= f.email_field :email %></p>

 <p><%= f.label :password %><br />
 <%= f.password_field :password %></p>

 <% if devise_mapping.rememberable? -%>
   <p><%= f.check_box :remember_me %> <%= f.label :remember_me %></p>
 <% end -%>

 <p><%= f.submit "Sign in" %></p>
<% end %>
</div>
<div class="half left">
       <h3>Create an account</h3>
       <%= render :partial => 'devise/registrations/form' %>
</div>
<div style="clear:both"><%= render :partial => "devise/shared/links" %></div>

Walter

On Jan 26, 2012, at 9:58 AM, Rodrigo Ruiz wrote:

> Hi, I'd like to know what is the best way to do this. Right now I can see two options:
> 1) create a new views at make a custom controller for registration controller to redirect to the right path
> 2) change the registration views that devise generates for you (so, for example, the new view will have the session view inside it for the sign in too)
>
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment