New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrading to Rails 3: Undefined method `key' for #<UserSession: no credentials provided> #101
Comments
I have the same problem, except it throws
Adding a custom to_key to UserSession will solve the undefined method error, but the form screws up. The form action contains a wrong path. It should target /user_session (or the route you set up), but it targets I have no clue how to fix that, but i'll investigate further. =) |
I just took a look at this again, and now I'm getting the to_key error method error aswell. I tried creating an empty to_key method in the UserSession model and now everything works. Where do Authlogic use the to_key method and for what? @russbuelt My form action path is good ("/user_session"). What does your form look like? |
@simonwh Oh yes the only difference: I have not added any activations or password resets to the sandbox app. AND i have not used Subdomains/accounts. My form: |
@russbuelt Does sounds wierd. I don't know a lot about authlogic so can't really tell why this is happening and why it need methods that doesn't really do anything (or so it seems). I guess your form builder line looks like the one I posted in my first message. I find it weird that it tries to link to the UserSession object aswell? |
There are some changes in the primary key handling in ActiveModel. They changed key to to_key. Adding this to your user_session model should completely resolve those key errors. =) Have a look at: |
@russbuelt That's it, good find. How do we notify the authors of this? (I'm new to github). |
@simonwh Thats pretty simple. I guess Ben is reading all those issues, and is already aware of this change. If you want to, you could simply visit his profile and send him a Message or mention his GitHub username (@username) an he will be notified. |
@russbuelt Great. Alright, it's all in your hands now @binarylogic. So do I close this issue? Since it has been solved for us, but not in the repository. |
@simonwh leave it open for now. Maybe someone could provide a patch at some time. This would be a good place to post it =) |
Or just fork the project, fix the bug and send a pull request. The steps are explained in the github help section. |
+1. This happens for me, too. I fixed it in my fork, and sent a pull request. Hopefully it will be fixed soon! |
Eh, I installed 2.1.6 and rails 3 rc and I still get this. I'm sending a PM to binarylogic in the hopes that he sees it, considering he's released a new version since voxxit sent a pull request and hasn't incorporated the fix. |
Seems that even with voxxit's branch when I generate a form from a UserSession object the path is "/user_sessions/%23%3CUserSession:0x104735d70%3E" |
I'm also receiving the /user_sessions/%23%3CUserSession ...." error after incorporating the to_key method into the user_sessions model. |
@heronog Don't know how I overlooked that, but that fixes it right up. |
Issue seems to be resolved with commit 5661867 to master |
Fixed it for me, I was getting this error from a generated resources view in Rails 3: ActionView::Template::Error (undefined method `to_key' for #<UserSession: no credentials provided>): 4: <%= pluralize(@user_session.errors.count, "error") %> prohibited this user_session from being saved:app/views/user_sessions/_form.html.erb:1... app/views/user_sessions/new.html.erb:3:... I removed the gem and installed this plugin via "rails plugin install git://github....." and now all is fine. Many thanks! |
When will this fix get distributed as a new gem version? |
I've been upgrading my app to Rails 3 this weekend and none of the above fixes work. The only fix I found was adding the following to my UserSession model: http://mrjaba.posterous.com/rails-3-active-model-undefined-method-tokey-f However, I'm not sure if this will cause issues down the road. |
I echo Mange's comment. Very confused about how this is being handled. It's annoying that the patch has existed for months and only recently got merged into master, but even now there is no gem version. It's just a minor annoyance that seems to indicate a lack of maintenance which is frustrating. |
Would be nice to see the gem updated with the latest code in master. Sounds like a lot of people depend on this gem! For those of you who are not afraid of living on the edge, you can force your rails app to use the latest code on github by adding the following code to your Gemfile:
After a quick 'bundle install', the problem seems fixed for me. |
@Emerson |
I also can confirm that latest code of github fixes this. Gem on rubygems.org seams to be outdated. So Ben could you please update this? Thanks! |
I also confirm this error! |
I just came back to check whether we could remove the fix from our application and use the newest gem instead ... the changes haven't propagated to the gems repositories yet, right? |
Cloning this repo, building from the gemspec, and installing the built gem worked fine for me. |
The gems should be in a better state now. Closing this now, let us know if anyone still gets it on the latest versions. |
I've been upgrading one of my apps to Rails 3 today and have run into some issues with AuthLogic. I've heard that it should work with Rails 3?
When trying to access the login view (/user_session/new)
Where line 3 is the form_for
Any clues? I'm thinking in the lines of it not recognizing the user model or alike, it does have the act_as_authentic as always though.
The text was updated successfully, but these errors were encountered: