Skip to content

Conversation

@jonathandean
Copy link

This is kind of an odd pull request because the instructions for Rails 3 that I added point to a fork of your project that added better Rails 3 support. I also admittedly did not update the actual app for Rails 3, just the instructions. However, I just thought you may or may not find this useful.

This commit you may want though, where I added the require_user and require_no_user methods to user_sessions_controller.rb: jonathandean@1aea9e2

Thanks for an amazing gem, by the way. I love authlogic and it has made my life infinitely better while porting over a legacy PHP app to Rails :)

@dlupu
Copy link

dlupu commented Dec 27, 2010

+1

@kimptoc
Copy link

kimptoc commented May 5, 2011

Would be good to get this added in now that authlogic is Rails 3 compatible :)

@BMorearty
Copy link

+1.

Newbies will benefit from these updates to the README. The current README makes no mention of bundler.

@gayle
Copy link

gayle commented Mar 3, 2015

+1. This helped me set this up on rails 4, too, since there's more similarities between 3 & 4, than between 2 & 3. The rails 3 instructions worked exactly for me except for a few things trying to render the views. I would fork and do a pull request to add to the instructions already in this pull request to add Rails 3 instructions, but not sure how. I know how to fork a repo, but I don't know of a way to fork an existing un-merged Pull Request such as this. So hopefully these comments help someone.

views/user_sessions/new.html.erb:
undefined method `error_messages' for #ActionView::Helpers::FormBuilder:0x6d8e8e0

Solution from http://stackoverflow.com/questions/10002140/use-error-messages-in-rails-3-2-raises-undefined-method-error says error_messages was deprecated in 3.2.

This worked well enough instead:

    <% if @user_session.errors.any? %>
      <% @user_session.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
    <% end %>
new.html.erb was showing blank with no form fields. When printing the value of @user_session, I got "no credentials provided"

This page http://techoctave.com/c7/posts/37-authlogic-and-rails-3-0-solution said the problem is calling UserSession.new without username and password. But the point of this is to have empty form fields so you can enter them. That page suggested changing the form helper like this

    <%= form_for @user_session, :as => :user_session, :url => { :action => "create" } do |f| %>

And that did give me empty form fields on the page.

views/users/new.html.erb, views/users/edit.html.erb, etc:

(from https://github.com/binarylogic/authlogic_example/blob/5819a13477797d758cb6871f475ed1c54bf8a3a7/app/views/users/new.html.erb)

Needed to put

 <%= form_for @user, :url => account_path do |f| %>

instead of

 <% form_for @user, :url => account_path do |f| %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants