Rails 3: Devise: No route matches "/" - ruby-on-rails-3

I'm running into some issues when trying to add Devise to my Rails 3 app. I started by creating a new Rails 3 (rc2) app with a "Home" controller and "index" action and verified that "/" would render "#home/index". Next I set devise 1.1.1 in my Gemfile, installed Devise, created a User model, and migrated the database. Now "/" returns No route matches "/" and none of the Devise routes will work.
What is the fix for this?

Apparently the latest gem version (1.1.1) of Devise does not work with Rails 3.0.0rc2. You must use the latest version from github.
Modify your Gemfile from:
gem 'devise', '1.1.1'
To:
gem "devise", :git => "git://github.com/plataformatec/devise.git"

Related

xray-rails not working with rails 5.1

I installed xray-rails on a Rails 5.1 app but pressing the keyboard shortcut does nothing. I already cleared cached assets rails tmp:clear. Any ideas?
Rails 5.1 dropped jQuery as a dependency. Add it to the Gemfile explicitly:
group :development do
gem 'xray-rails'
gem 'jquery-rails' # add it outside the group if you need it globally
end
Then import it in application.js:
//= require jquery
And you can Cmd + Shift + X again.

config.active_record.whitelist_attributes = false in Rails 4.2 App

Our rails 4.2 app consists of several rails engines with or without gem 'protected_attributes'. What we find out is that in app's application.rb, it has to be:
config.active_record.whitelist_attributes = false
Otherwise, any create/update can not be carried out because the params can not be assigned to instance variable. Our question is that, if there is no gem protected_attributes in rails app, do we still need config.active_record.whitelist_attributes = false in application.rb? Is this for Rails 3.x or app with gem protected_attributes?
I've looked through several rails 4 apps I have, none of them contained that config, and when I googled the config name, the protected_attributes gem came in the results, so I think you could assume that it's only related to the protected_attributes gem and that you don't need it
This comes from the protected_attributes gem.
When whitelist_attributes = true it causes attr_accessible(nil) to be added by default for all models meaning you ca not mass assign any attributes for any models unless it has its own attr_accessible or attr_protected
This can be seen in an older version of the README.md
As of version 1.1.2 this is now depreciated and does nothing other than log a depreciation warning
So if you are on a Rails 4+ application and do not have the protected_attributes gem then you can safely remove it

Rails 4.0 & Devise - Strong Parameters error

Newbie to rails here, so bear with me.
New app on Rails 4 with ruby 2.0, I installed Devise and followed the instructions(default root, etc). Devise readme on github says it should be compatible with rails4 but
db:migrate failed unless I commented out attr_accessible line in User.rb
After commenting that out, I get "ActiveModel::ForbiddenAttributesError in Devise::RegistrationsController#create" error in trying to create a user.
I see some stack overflow questions like this, but a lot of the answers jump straight into some complex talk. I get I need to specify permitted attributes for mass assignment, but how? And where? And which attributes need to be permitted, all of them? Only those that I expect to be changed/created at the same time?
Judging by the error would I create a registrations_controller.rb that inherits from Devise::registrationsController ? What do I specify in that?
Any step by step, newbie friendly answers are much appreciated. I've exhausted myself trying different code from answers here and various sites from google searches.
Welcome to stackoverflow!
The problem is that the functinality of attr_accessible changed in rails 4.0
2 possibilities to get it running
1 Update Devise that it can handle Rails 4.0
Add this line to your application's Gemfile:
gem 'devise', '3.0.0.rc'
And then execute:
$ bundle
2 Add the old functionality of attr_accessible again to rails 4.0
Try to use attr_accessible and dont comment this out.
Add this line to your application's Gemfile:
gem 'protected_attributes'
And then execute:
$ bundle
Adding below gems and doing a bundle install worked for me
source 'https://rubygems.org'
gem 'rails', '4.0.2'
gem 'bootstrap-sass', '2.3.2.0'
gem 'devise', '3.0.0.rc'
gem 'protected_attributes'
gem 'sqlite3'

no such file to load -- google_chart using gem gchartrb

I am trying to use the gem gchartrb to create some graphs/charts in my RoR application.
I have looked into several tutorial and all say the same thing, that I have to add
require 'google_chart'
But I am getting the message:
no such file to load -- google_chart
I have the require inside my controller, I have confirmed that the gem is installed.
I am using Rails 3.
Also, I have tried adding config.gem 'gchartrb', :lib => 'google_chart' in my environment.rb as suggested here but nothing changed
Thanks for your help
EDIT:
I have also tried with the gem googlecharts, what I have in my Gemfile is:
gem "googlecharts", :require => "gchart"
but I get no such file to load -- gchart when I try to load the view.
I am not sure, it is required now or not. But it worked for me in Rails 3 as well. I am using Rails 3.0.10. I added below 2 lines and it worked for me.
1) gem 'gchartrb' in Gemfile
2) require 'google_chart' in config/boot.rb
Hope it helps!
config.gem is for rails 2.3.X.
For rails 3, you will need to add the gem to your Gemfile and run gem bundle
You may also need to check that the google_charts gem actually supports Rails 3...
Given that the latest code update seems to have been in 2008 - that might not actually be likely. :(
You can try it anyway and see...

omniauth w/ Twitter not working on rails 3.1.0.rc5

I have a Rails app running on 3.1.0.rc5, and I've setup omniauth for twitter exactly the same as seen here (https://github.com/sferik/sign-in-with-twitter) but it's still not working.
The problem is that after Twitter is redirecting back to my callback URL I have request.env["omniauth.auth"] is nil, rack.auth is nil too. I even went so far as to print out the entire request.env hash and didn't see anything like access_token or access_secret.
The only thing that doesn't look like my request token and secret is stored in action_dispatch.secret_token.
Any ideas on how to make this work?
Ok, so I got this working now. My Gemfile was:
gem "oa-oauth", :require => "omniauth/oauth"
gem "twitter"
I changed it to:
gem 'omniauth', :git => 'git://github.com/intridea/omniauth.git'
gem 'twitter'
gem 'json_pure'
gem 'json'
And everything started working. The request.env["omniauth.auth"] key was present etc. I had to add the json gem lines because of a uninitialized constant JSON::ParserError error I was getting. I think that is a bug in the release candidate.