undefined method `secret_key=' for Devise:Module (NoMethodError) - devise

I am using devise with Rails 4. I had a problem with some fields not rendering in the user views and I realised it's because of the attr_accessible that's not supported any more so I had a look around and came to the conclusion I should use the latest version of the gem (3.0.3).
And that's when the problem appeared:
I cannot run any rails commands now as I am getting the undefined method 'secret_key=' for Devise:Module (NoMethodError) error and it's not going away even if I downgrade the gem.
Rolling back to some previous git commit doesn't solve it, remove the gem and doing a bundle install again doesn't solve it, and I starting to think I should probably start from scratch.
Does anyone know how to walk past this?

I believe this setting is only available in the more recent versions of Devise, 3.1.x and above. You should either upgrade the gem to this version or remove that line that references secret_key= from your config/initializers/devise.rb file.

Related

Bundler not updating when it says it has in rails 3.2

I am using the best_in_place gem. Unfortunately, the update code on the gem was not working properly but a solution had been found and merged into the latest alpha version of the gem. Initially I simply edited the gemfile and added the fix but I know that is bad practice so I added:
gem 'best_in_place', github: 'bernat/best_in_place'
to get the latest version. I bundle installed and it said this:
Using best_in_place (3.0.0.alpha) from git://github.com/bernat/best_in_place.git (at master)
But, when I go and look at the actual file it has not been changed.
Run bundle update best_in_place to update to the latest commit.

New Relic ActiveRecord::ConnectionNotEstablised Rails 3.2.3 error

I just installed the newrelic_rpm gem in my RefineryCMS Rails 3.2.3 application. I copied in the newrelic.yml config file as per the instructions. My app is being deployed with Heroku on the Cedar stack, so the instructions were pretty simple.
https://devcenter.heroku.com/articles/newrelic#cedar
However, running "rails server" on my development box gave me this error message:
/home/xxx/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `retrieve_connection': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
Setting the agent_enabled value to "false" in the newrelic.yml file allowed the server to start up again. Setting my license key and app name environment variables made no difference.
Interestingly, even though I couldn't get the app to start on my dev box, when I deployed it to Heroku, everything worked fine - and I am now getting new relic stats. Great!
My workaround has been to remove newrelic_rpm from the gemfile (which is what the install instructions say to do), and put it only into a :production group. Obviously, new relic is only useful in production, so it's no big deal.
group :production do
... other gems
gem 'newrelic_rpm'
end
Anyone else ever experienced this, or know why it should be causing an ActiveRecord error (with no mention in the error trace of new relic at all)?
The issue you were running into looks like a bug in the newrelic_rpm gem that was addressed with our (I work at New Relic) recent 3.6.4 release. I'd suggest that you try updating to 3.6.4 to see if the issue persists.
By way of explanation: we have something in the newrelic_rpm gem called an EnvironmentReport, which gathers information about the environment your application is executing in (Rails version, gem versions, DB adapter, Ruby version, etc) to display in the UI. In version 3.6.0 of the newrelic_rpm gem, we pushed the generation of the EnvironmentReport into a background thread. Because the EnvironmentReport potentially referenced the ActiveRecord::Base constant, generating it could trigger some ActiveRecord initialization code paths that are not thread-safe. If the EnvironmentReport happened to hit ActiveRecord::Base at just the wrong time, it could trigger errors like what you were seeing on the main thread.
We addressed this in 3.6.4 by moving the generation of the EnvironmentReport back onto the main thread.
Sorry for the headache, and please let us know if 3.6.4 doesn't solve your issue.
Edit - hmm, just noticed that you asked about this before 3.6.0 was released. I'd still suggest trying 3.6.4, since I suspect a similar race condition may have existed in older versions of the newrelic_rpm.

undefined local variable or method `config' for main:Object (NameError) when running rails server

Hi I've been following a tutorial for authlogic gem in railscasts... http://railscasts.com/episodes/160-authlogic?view=asciicast
From the tutorial, I was asked to add config.gem "authlogic" in my environment.rb
Is it the old way in installing a gem? or the right way to make authlogic work?
I removed the config.gem "authlogic" and tried to install the gem using gem install authlogic and by putting gem 'authlogic' inside my Gemfile (then bundle it)
Authlogic gives automatic form validation (when there's no input or what)
But it is not working. It could be possibly that I didn't install the authlogic gem properly?
What do you think is the problem why my Authlogic gem is not working..
Given the age of the Railscast, it's a good bet that the installation procedure is outdated. Luckily, the authlogic github page has not only updated install instructions (it is, as you'd expect and predicted, adding gem 'authlogic' to your Gemfile), it also has links to assorted tutorials and documentation. Hopefully you can use those to sort out your issue.

Authlogic Base.named_scope Deprecation Error

I'm using Authlogic 2.1.6 in Rails 3.0.1.
Everything works fine but I am consistently getting the same two errors, which stem from the acts_as_authentic command in my user model.
DEPRECATION WARNING: Base.named_scope has been deprecated, please use Base.scope instead. (called from <class:User> at /Developer/Products/sphr/app/models/user.rb:271)
I recall seeing an Authlogic commit that claimed to have fixed this bug but I can't find it.
Could you please tell me how to stop seeing these messages?
Thanks!
The calls to the deprecated methods have not been fixed in the master Authlogic repository. There are about two dozen pull requests fixing them on Github, though. If you feel so inclined, you can simply change your Gemfile to point to one of them instead.
gem 'authlogic', :git => 'git://github.com/exceed/authlogic.git'
Update: Those pull requests have finally been integrated in and you can use the standard gem again.

vestal_versions

I was watching railscasts episode 177, as I need to implement some versioning in my app. But this episode was not done in Rails 3. So i went to the site of the gem itself.
https://github.com/laserlemon/vestal_versions
Now, it says it was tested with Rails 3, but even placing that line in the gemfile didn't let me install it. I just installed using gem install etc.
Now to even generate the migration is an issue, as I get the error
$ rails generate vestal_versions:migration
Could not find generator vestal_versions:migration.
Has anyone managed to succesfully use the gem that could give me advice?
Thanks a lot!
Do you have this line in your Gemfile?
gem 'vestal_versions', :git => 'git://github.com/adamcooper/vestal_versions'
and ran bundle install? That's the one that is in the readme on github and works for me. I had the same error of the missing generator when I used
gem 'vestal_versions'
in my Gemfile, which fetches the gem from rubygems.org, which is pretty old and does not contain the proper generators yet. Using the gem from Github should work.
Btw, I'm not sure which fork on github is the best. There are several that do contain some fixes.