I am using devise gem, I had install the gem also but I am still getting error as below:
no route matches[Get] "/dhwani_app"
In your routes try adding
"devise_for :(whatever your model is)" but obviously don't put the quotations in
Related
I am using the Gem shopify_app (https://github.com/Shopify/shopify_app) to build an embedded Shopify app. In the file login_protection.rb there is this method:
def redirect_to_login
session[:return_to] = request.fullpath if request.
redirect_to login_path(shop: params[:shop])
end
I am getting the above error message, that login_path is not found. Since nobody else is complaining about this, I'm almost certain I am missing something very simple but I really am stuck. Does anybody have any pointers to help me out?
Try running
rake routes | grep login
This should tell you what paths you have defined that contain login in them. Otherwise just run rake routes and ensure that login_path, or whatever path you are looking for exists.
Also you may have a syntax error here:
if request.
You are calling no method on request.
The problem was that in version 5.0.1 or 5.0.2 (I was upgrading from 5.0.0) a named route called login_route was introduced. Usually apps have this route, either explicitly named or derived by Rails from the URL /login. I instead used /shopify/login as URL to my login page so my derived route name was shopify_login instead. All in all I've been looking in all the wrong places and didn't the forest for the trees so I was stuck. Just make sure this named route login exists and everything is good.
Simple question.
I'm using Rails 4.1.4 and Devise 3.3.0 for my app.
I'm trying to generate Devise's controllers so I can override some behaviour.
Documentation says to run...
rails generate devise:controllers [scope]
... to generate controllers under app/controllers/scope so you can then modify them. But when I run the previous command it keeps saying that there is no generator devise:controllers:
Could not find generator devise:controllers.
Does anyone knows why?.
Thanks.
UPDATE
In fact, when I run...
rails generate
... to retrieve a list of the available generators, I get the following output for Devise generators:
Devise:
devise
devise:install
devise:views
So definitelly, the devise:controllers generator isn't there. Is there a way to add it?. How?.
Thanks.
SOLVED
I've just created the controller manually and make it inherit from Devise. For example:
class Users::RegistrationsController < Devise::RegistrationsController
# Override the action you want here.
end
This controller should live in app/controllers/users/registrations_controller.rb. If you have any other scope just go with app/controllers/scope/registrations_controller.rb. For example if you have an admin scope it would be app/controllers/admins/registrations_controller.rb.
Best.
UPDATE
Following the comment from blushrt, I forgot to mention that it is important to modify config/routes.rb to make Devise use the created controller for the specific resource. For example, for users, you should put in your config/routes.rb:
devise_for :users, controllers: { registrations: "users/registrations" }
That's it. Best.
To answer the OP's original question of "Does anyone knows why?"
The problem is that this generator is currently only available on Devise's master branch, as stated on this GitHub issue.
If you want to use this feature before it's published, you could add this to your Gemfile:
gem 'devise', git: 'https://github.com/plataformatec/devise'
https://github.com/plataformatec/devise/wiki/Tool:-Generate-and-customize-controllers
You can run this command in your terminal.
bash <(curl -s https://raw.githubusercontent.com/foohey/cdc/master/cdc.sh)
Putting this here in case anyone else has this (silly) problem. I couldn't work out why a POST to /users kept routing to Devise::RegistrationsController#create rather than Users::RegistrationsController#create
The reason?
I had a typo in routes.rb
devise_for :users, controllers: { registations: 'users/registrations }
Note I had registations instead of registrations
So be wary you may have a typo in your route somewhere
Cant figure out what I'm doing wrong.
Using hidemyass gem for proxy.
Using github example code.
class HomeController < ApplicationController
require 'hidemyass'
def index
HideMyAss.options[:max_concurrency] = 3
response = HideMyAss.get("www.google.com", timeout: 2)
end
end
Whey I try to use them in my rails controller, I get the Uninitialized constant error.
uninitialized constant HomeController::HideMyAss
Tried looking at the source to figure out with no luck. Maybe it's the problem with my code. Gemfile is good and tried looking at all the things causing the problem.
There is no need to write require 'hidemyass'
You just need to add gem 'hidemyass' to Gemfile and do bundle install. Check installation with gem list hidemyass command. I have successfully checked it and used github example. It works fine and smoothly.
When I add this to my gem file ( rails 4.0.1 )
gem 'rails-api', git: 'https://github.com/rails-api/rails-api.git', branch: 'master'
My routes seem to break (although rake routes is the same before/after)
I get this after I attempt to update a simple scaffold model
No route matches [POST] "/surveys/1" when I update a record
by commenting out this gem it works again - any ideas what I did wrong?
thanks!
PS: Adding this to gem file so I can use strong parameters to follow railscasts#196 in rails 4
Adding this to gem file so I can use strong parameters to follow
railscasts#196 in rails 4
Perhaps your app is having a problem with what you're using this gem for. I don't know if you've just upgraded to Rails 4, but the latest version uses Strong Params by default
The Railscast seems to be involved with loading nested forms. We do this all the time without the rails-api gem - can you let us know what you're trying to use this gem for specifically?
I've gotten my application to work (i.e. sign_in and sign_up) with Authlogic and I'm now trying to add support for OAuth through the Authlogic_OAuth gem. I've gotten all of the basics set up (I think) and I've added a "Login with Twitter" button to my landing page. The problem is that when I click the button I get this error:
uninitialized constant UserSession::OAuth
with the application trace:
app/models/user_session.rb:17:in `oauth_consumer'
app/controllers/user_sessions_controller.rb:23:in `create'
The function that is failing is in my user_session model:
# authlogic_oauth hacks
# Twitter example
def self.oauth_consumer
OAuth::Consumer.new("TOKEN", "SECRET",
{ :site => "http://twitter.com",
:authorize_url => "http://twitter.com/oauth/authenticate"})
end
I'm pretty new to rails and ruby so I don't quite understand where this namespace collision is coming from or how to solve it. Any help would be greatly appreciated.
OK, I figured it out. The problem is that OAuth::Consumer is not defined withing authlogic_oauth. It's actually defined in the oauth gem. so I updated my Gemfile to:
gem 'authlogic', '2.1.6'
# set up oauth capabilities. Note: :lib is replaced with :require in rails 3
gem 'authlogic-oauth', '1.0.8', :require => 'authlogic_oauth'
gem 'oauth', '0.4.4'
then run:
bundle install
and, don't forget to restart the rails server so that it reloads the gems from the Gemfile.
Try to change OAuth to ::OAuth. The colons mean that you want to access OAuth from outside your class. It was searching from your class.