FAQ Database Discussion Community


double nested form with devise and geocoder not showing

ruby-on-rails,devise
I am using complex nested form. I have 3 models Location class Location < ActiveRecord::Base has_many :events has_many :profiles geocoded_by :address end Profile class Profile < ActiveRecord::Base belongs_to :user accepts_nested_attributes_for :user belongs_to :location accepts_nested_attributes_for :location end User (Devise) class User < ActiveRecord::Base has_one :profile, dependent: :destroy accepts_nested_attributes_for :profile end In...

links from excel to rails server running devise not working properly

excel,ruby-on-rails-4,devise
(rails 4, ruby 2.0, excel for osx 14.5, but same problem detected in windows excel) I have a link in excel that looks like: https://www.example.com/reports/download_frame/1481 When the user clicks in excel they get routed to the default home page. When they cut and paste the same url into a browser...

what s wrong with my authentication system in the actual heroku app?

authentication,heroku,devise,omniauth-facebook
I tried to implement logging and sign up with devise, omniauth and facebook. Now it looks like the facebook implementation works but whenever I try to log in the hroku site through facebook, it renders an error and says: "Check your logs. Here are my logs: 2015-05-17T18:23:35.994186+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/application.rb:144:in `call'...

How to test Devise user was created with proper password with RSpec

ruby-on-rails,ruby,rspec,devise
Is there a way to test that a Devise user was created with the correct password in RSpec? I have a feature spec for creating a user, and have tried testing that created_user.encrypted_password eq User.new(password: same_as_created_user).encrypted_password but the passwords generated do not match....

Google authentification with “devise” fail

ruby-on-rails,devise,google-oauth,omniauth
I want to create a GOOGLE authentification in my app. So in set up "omniauth" and "devise" correctly (I think). In my layout folder in "_header.html.erb" view : <% if user_signed_in? %>Signed in as <%= current_user.name %>. Not you? <%= link_to "Sign out", destroy_user_session_path,:method => :delete %> <% else %>...

correct syntax postgresql query with two conditions, rails, eula acceptance / version test

ruby-on-rails,ruby,postgresql,devise,authorization
At time of login, I am trying to evaluate whether or not a user has accepted our current end user license agreement ( eula ). In the contracts-controller.rb def eula_version eula_version = "3" end In the application_controller.rb, an after_sign_in_path_for(resource) method per the devise gem instructions def after_sign_in_path_for(resource) if @user =...

Customising Devise registration edit/update routes and views

ruby-on-rails,ruby,devise
I've just started using Devise and I've made some customisations: I've generated views and customised my views (signup form etc) I've generated controllers so I can make some changes there I've customised routes, mostly as per this post: http://iampedantic.com/post/41170460234/fully-customizing-devise-routes Everything works great except the edit_user_registration stuff (the view where users...

NoMethodError undefined method sign_in rspec devise

ruby-on-rails,rspec,devise
Given that I am trying to write a simple rspec test whilst using devise I seem to keep NoMethodError: undefined method sign_in I have the following setup but cannot seem to get around this. I did come across another similar question to this Rails, Devise, Rspec: Undefined method 'sign_in' and...

Rails double render error despite using if then statement

ruby-on-rails,ruby-on-rails-4,redirect,devise
I frequently use both render and redirect_to but combining in an if...then statement so that the action by default only has 1. Not sure why this is not working in this case with Devise. What I need to do is whether a user is confirmed or not, immediately after s/he...

devise sign in page always show up even though its not root.

ruby-on-rails,devise
It says log in to continue. I ve completely removed all excess from layout.html.erb Only render tag is part of the body. Yet it keeps routing to the users/sign_in page Help!...

When does Devise actually send reconfirmation emails?

ruby-on-rails,ruby,ruby-on-rails-3,email,devise
I'm trying to add email confirmation to a model called "Project" in a Rails app: users should be able to set an email address for a project, which is not saved until they click a confirmation link sent to the email address provided. Although I have no need for its...

Devise configuration

ruby-on-rails,devise
I currently want to make a login with devise. On top of email and password I want to have an username. I generated the migration: class AddUsernameToBuyer < ActiveRecord::Migration def change add_column :buyers, :username, :string add_index :buyers, :username, unique: true end end I also added username in the sign-up view:...

Rails Trying to create a profile after the user has been created

ruby-on-rails,ruby-on-rails-4,activerecord,devise
I'm trying to figure out how to create a new profile for the user that has just been created, I'm using devise on the User model, and the User model has a one to one relationship with the UserProfile model. Here's what my User Model looks like: class User <...

Two users#show, and how to redirect to my user profile after login

ruby-on-rails,ruby,devise
Happy Thursday everyone, I had a quick question on routes and redirecting. I am working on a rails assignment that asks that I redirect the router to his/her profile after signing in. How would I go about doing that? An after_sign_in method? Here is my routes: Rails.application.routes.draw do get 'users/show'...

Changing nav-bar links according to whether a user has created a profile or not (RoR)

ruby-on-rails,ruby,if-statement,model,devise
I'm making a rails app and have created a simple navbar that works fine. I have set up devise and created a profile model which I would like users to create after they sign up, and (I believe) I have correctly made the necessary associations. As a new user signs...

Linking a user id to a profile model - Ruby on Rails

ruby-on-rails,ruby,model,devise,scaffolding
I have a basic rails app with devise set up and a profile model generated with scaffolding. The Profile model is where the user will add detailed information about themselves after they sign up. Everything is working fine except for one issue: after the user creates a profile, the new...

Rails on create transaction

ruby-on-rails,devise,transactions
On creating a new user (in my user model) i want to create a stripe customer as well. The two actions must only be completed if they succeed together (like i don't want a customer without a user and vice versa). For this reason I figured it would be a...

RSpec controller test error: controller does not implement method

ruby-on-rails,ruby-on-rails-4,rspec,devise
I've written some custom code for Devise registration. Namely once a user hits the "sign up" button, Devise's generic code ensures that the user is saved correctly. But then, I want to go in and make sure that the user gets an associated Stripe customer account. Most of the code...

Using a curl command to login to rails api with devise

ruby-on-rails,ruby,curl,devise
I have a simple web app built with rails using devise for user log in. At the moment a user can sign up, sign in and sign out, and make new posts when signed in. Eventually I plan to make this api consumable via a mobile app and my first...

Rails - Devise : Check if user can sign in

ruby-on-rails,devise
I use devise to deal with Session. I need to check if a user is validate by admin before sign in. I added a boolean field in my model 'is_validated'. How can I check this field before sign_in a user ?...

Instance variable in partial view

css,ruby-on-rails,ruby,twitter-bootstrap,devise
I have a navbar that is a partial view that I need to render on a devise page for the user to edit their profile. As it is, I only have one page, but adding the path to perform account maintenance has messed up my navbar loading because of the...

Ember CLI Rails: Creating user model

javascript,ruby-on-rails-4,ember.js,devise,ember-cli
Ember (0.2.5), Rails (4.2), Ember CLI Rails, Devise, Ember CLI Simple Auth Devise Action for creating the user model on the 'user/new' controller. Currently the ruby code creates the user in the database however the javascript response is still failing. I haven't been able to find much resources on Ember...

How do I render my items#show partial within a user profile?

ruby-on-rails,devise
Good morning everyone! I am working on a rails assignment, and I am having some trouble rendering my items partial within a user profile. I believe the problem is that the @item variable is not initializing when within the user's views? Whenever I add a new item to a user's...

Devise Passwords Controller JSON params not working

ruby-on-rails,json,devise
I'm trying to hit the Devise PasswordsController using JSON. I've overriden the controller to respond to JSON. class PasswordsController < Devise::PasswordsController respond_to :json end I'm passing the params via JSON (using Postman) with the Content-Type = application/json. I'm trying to POST to /users/password. The params look like this: { "user":...

can a PORO access the database?

mysql,ruby,ruby-on-rails-4,devise
as my first Rails app, I am building a homework management app which has these tables: users (from Devise authentication) schools courses assignments Unlike most examples of course/grading apps I've found, this one is never concerned with all the grades for all students for a particular course, but has only...

devise_security_extension :install command not working

ruby,ruby-on-rails-4,devise
rails 4.2.1.rc4, devise 3.5.1, devise uid 0.1.1, devise_security_extension 0.9.2 the generator finishes with "insert config/initializers/devise.rb" and installs the locale files but, there is no new information added to devise.rb and there is no devise_security_extensions.rb file. is there a fix? or manual install?...

Sending MailChimp email with Rails

ruby-on-rails,email,devise,mailchimp,mandrill
((I've found similar questions to mine, but they are specific to a 3rd party mandrill gem, or Heroku. I'm not using any of those, just the mandrill-api itself.)) I'm trying to use email confirmation (we use Devise) for account creation. I've set up confirmable, everything with that works well. Initially,...

using devise WITHOUT the gem, can I simply copy the files?

ruby-on-rails,ruby,devise,gem,rubygems
Could I simply copy the devise app and lib (and gem?) folders into my respective project folders and have them work just as if I was using the gem? I'd like to do this so that I can really see all the code, possibly do some customization, and also avoid...

Difference between “super” and “super do |u|” using context of Devise

ruby-on-rails,ruby,ruby-on-rails-4,devise,super
Ok so I think I get what super does standalone. Basically in Devise, if Users::RegistrationsController < Devise::RegistrationsController, then on any action, having a super will first call the logic for that same named action in the parent Devise::RegistrationsController, before then calling what you've written. In other words... class Devise::RegistrationsController def...

Authenticate two different devise classes in same controller in Rails

ruby-on-rails,ruby,devise
I have this view called Intranet where only authenticated "devise clients" can access. class IntranetController < ApplicationController before_action :authenticate_client! def index end end On the other side, I also have other "devise admin", this devise admin requires to access the same view. How can I handle this situation?...

Devise - user session still valid after sign out

ruby-on-rails-4,devise
Here is the scenario: 1. start the app 2. sign in as a user having remember_me = true 3. close the browser 4. restart the browser, user shown as signed in. 5. click on the sign out link. 6. Home or "/" page is rendered but user still shown as...

Devise and Rolify - Display all of users - roles — Multiple Roles

devise,user,roles,rolify
I have a view that shows the user and roles. I can get it to show all of the users and a single role with user.roles.first.name. I cant get it to loop and retrieve all roles for the user selected. Any help would be wonderful. <h1>Admin#users</h1> <p>Find me in app/views/admin/users.html.erb</p>...

How to check status of invitation?

ruby-on-rails-4,devise,devise-invitable
For each User I want to display his invitation status: "Invitation Sent" or "Invitation Accepted" Currently I just check if a field encrypted_password in Users table contains anything. If it is not - then a user did not registered (accepted an invitation) yet but it was sent to him (otherwise...

skip authorization for specific controllers using pundit in rails 4

ruby-on-rails,devise,pundit
I am using rails 4, devise for authentication and Pundit for authorization. I have restricted my application to check for authorization on every controller by below code. class ApplicationController < ActionController::Base include Pundit after_action :verify_authorized #..... end However, i want to skip authorization for two specific controllers in my application...

How to programmatically list all devise routes

ruby-on-rails,ruby,devise,routes
I'm using devise to authenticate my users in my Rails 4.1.9 application. I need to list all devise routes in a javascript file. I tried to do something like this: all_routes = Rails.application.routes.routes.map do |route| route.path.spec.to_s.gsub('(.:format)', '') end This simply prints all rails routes. How can I get only devise...

Rails Stripe: How do I cancel subscription?

ruby-on-rails,ruby,devise
I'm using devise and in devise/edit I had put a "cancel my subscription" button but I'm not 100% how to get it to work. How do I allow users to unsubscribe from stripe? Here is the error I got, any help is appreciated edit.html.erb <%= button_to "Cancel my Subscription", canceled_path,...

rails - error loading “new” page made with ruby on rails scaffolding

ruby-on-rails,ruby,devise,scaffolding
I have a simple rails app with devise set up and a profile model that I created. I have set up my associations and everything seems fine, however when I try to access the new_profile_path with a new user account, I get the following Error: NoMethodError in ProfilesController#new undefined method...

Ruby On Rails: Duplicate Index User listing

ruby-on-rails,ruby,devise
I have Devise installed and have set up a UsersController. My UsersController looks like the following: class UsersController < ApplicationController def index @users = User.all end end My routes currently look like this: Rails.application.routes.draw do root 'users#home' devise_for :admins devise_for :users, controller: :users scope "/admin" do resources :users, only: [:index,...

How do I redirect the user to his/her profile after signing in. An after_sign_in method?

ruby-on-rails,devise
Happy Thursday everyone, I had a quick question on routes and redirecting. I am working on a rails assignment that asks that I redirect the router to his/her profile after signing in. How would I go about doing that? An after_sign_in method? Here is my routes: Rails.application.routes.draw do devise_for :users...

Simple learning app with Rails 4 - Course / Enrolment / User Not working

ruby-on-rails,ruby-on-rails-4,devise
I am trying to build a simple learning app with rails 4. here are my models: class User < ActiveRecord::Base has_many :enrollments has_many :lectures, through: :enrollments accepts_nested_attributes_for :enrollments end class Enrollment < ActiveRecord::Base belongs_to :user belongs_to :lecture end class Lecture < ActiveRecord::Base has_many :enrollments has_many :users, through: :enrollments end And...

Rails 4 delete button logs me out and results in “Can't verify CSRF token authenticity”

ruby-on-rails,ruby-on-rails-4,devise
I'm running Rails 4.2, Devise 3.4.1, and CanCan 1.6.10. When I try to delete resources via a standard delete button like the following one, I get signed out and redirected to the login page. <a data-confirm="Are you sure?" class="btn-alert" rel="nofollow" data-method="delete" href="/admin/lots/6">Delete</a> My dev log tells me it's because it...

ActiveAdmin Devise Cancancan and Three User Models — infinite loop

ruby-on-rails-4,devise,activeadmin,infinite-loop,cancancan
I'm currently running three user models. Staff, customers and suppliers. Each has a devise model and I can seem to nail how to authorize only Staff to get to the activeadmin pages. I have managed to get one Model to access it but then the other two go into a...

One page on Bootstrap 3/Rails site isn't mobile responsive (the others work)

html,css,twitter-bootstrap,ruby-on-rails-4,devise
Thanks to the answer to my previous stackoverflow question, I was able to make the bootstrap 3 layout on my Ruby on Rails 4 app MOSTLY mobile-responsive. However, my views/devise/sessions/new.html.erb page (aka the login page) isn't responsive. Instead, it looks like this on my iPhone 5s: This is my new.html.erb...

How do I cycle through an object and it's nested objects before moving on to the next object in Rails?

ruby-on-rails,ruby,devise,cocoon-gem
I'm a beginner at RoR. What I'm trying to accomplish is to cycle through a list of service_types (brakes, drums, pads, etc...) per service category (brakes) belonging to each tech before going on to the next service category (suspension). I have a setup with the following: Gems devise: user signup...

Migrate from existing password_digest column?

ruby-on-rails,ruby-on-rails-4,devise,bcrypt
I have a custom User model with lots of rows. I have a password_digest column that I want to keep. (it comes from has_secure_password) And I also want to use Devise database authenticatable, but from my limited knowledge on Devise, I have to use the encrypted_password column. Is there a...

Rails 4 how to make enrolment to a course for users (controller, view, model)

ruby-on-rails,model-view-controller,devise
I am currently trying to build a simple learning app with rails and I am facing problems. When a user signs up to a course i try to make a viewed_course record for them so that I can display all the viewed_course on their profile page. I can't figure out...

Missing devise mailer template

ruby-on-rails,devise
I'm getting a missing template error with devise - it's probably a simple error but I can't see it. I have - ../mailers/user_mailer.rb class UserMailer < ::ActionMailer::Base include Devise::Mailers::Helpers default :from => "[email protected]" def confirmation_instructions(record, token, opts={}) @token = token devise_mail(record, :confirmation_instructions, opts) end ... ...and a template generated by...

Authenticated user making AJAX requests to rails API from jQuery

jquery,ruby-on-rails,ajax,authentication,devise
I'm building a Rails app and I'm using Devise for authentication. When the user is logged in I need to make an AJAX call to Rails and get data that belongs to the current user as JSON. Also I don't want unauthenticated users and other logged-in users to access the...

Signout from a controller in rails 4

ruby-on-rails,devise,controller
I want to signout from a controller. My controller looks like def update if @attendance.update_attribute(:logout_at, Time.now.localtime) redirect_to signout_path and return end end And my routes looks like devise_scope :employees do get "signout" => "devise/sessions#destroy" end devise_for :employees, :controllers => { registrations: 'registrations' } But It gives error Unknown action Could...

Devise authenticating with additional field company_id

ruby-on-rails,devise
I'd like to authenticate user with company_id beside email, password (Devise's default). I just searched Devise wiki sign-in-using-their-username-or-email, and Scope-login-to-subdomain I just find out about Devise, and I am not good to understand clearly. So, someone guide me how to add new field for authenticating. How to change the Devise...

Devise emails are not being sent using sendgrid while other emails are being sent well

ruby-on-rails-4,heroku,devise,sendgrid
I am using sendgrid to send emails in production my all other emails are being sent as expected but all the devise emails are not being sent neither a crash occur my in my production.rb I have config.action_mailer.raise_delivery_errors = false config.action_mailer.default_url_options = { :host => 'myapp.herokuapp.com' } config.action_mailer.delivery_method = :smtp...

devise_token_auth:install in a rails app does not run

ruby-on-rails,ruby,ruby-on-rails-4,devise
I'm trying to start a project with devise_token_auth with the instructions of README.md file. When i run rails g devise_token_auth:install User auth the console becomes locked and does not display any messages. To create my project i followed these steps: rails new foo cd foo bundle install #then i add...

DB issue in rails? Rails query and SQL query return different results (default_scope's fault?)

ruby-on-rails,postgresql,ruby-on-rails-4,activerecord,devise
We have over 29K users in our database. "User" is one of our tables and has a unique field "email" with an index defined in one of our migrations: #3434324_devise_create_user.rb class DeviseCreateUsers < ActiveRecord::Migration def change create_table(:users) do |t| t.string :email, :null => false, :default => "" end add_index :users,...

How to exclude guest users from getting emailed Rails 4 Devise

ruby-on-rails,email,ruby-on-rails-4,devise,mailer
Just set up my first mailer on Rails 4. I have a welcome email sent to new users as soon as they sign up (create) for a new account using devise. I also have devise set up so that if a current_user is not found, a guest user will be...

Can not log out in rails with devise due to invalid authenticity token

ruby-on-rails,devise
So I'm stuck on this weird problem, which somehow I have never experienced before; and somehow I cannot find anything anywhere on how to solve it. So my problem is this: When I'm logging out with this link link_to "sign out", destroy_user_session_path, method: :delete It crashes the application with this...

How to associate user to IPN

ruby-on-rails,paypal,devise,paypal-ipn
I am using rails to create an app where a use can by coins useing paypal. I am using a generic buy now button created on the Paypal site. I have the button is set to give a IPN to a URL on my website. Previously I had issues with...

Rails and DocRaptor, override authentication

ruby-on-rails,devise
I'm using Rails 4 and DocRaptor in order to convert an html page to pdf. The problem is I'm also using devise 3 for authentication. Devise's log in page is the root if you're not authenticated. Therefore, when DocRaptor pulls the html from a show page, it actually pulls the...

generating meaningful usernames in devise

ruby-on-rails,ruby,devise
I'm trying to have my app automatically generate usernames to be used as the url. Typically they will be the users first and last name added together however when there already exists a user with the same first and last name it will append a number to the name that...

Devise wrong redirect using devise_scope

ruby-on-rails,devise
If I enter an invalid username or password in /admin/sign_in. Devise redirect to /administrators/sign_in instead of /admin/sign_in. This is my routes.rb devise_for :administrators devise_scope :administrator do get "/admin/sign_in" => "devise/sessions#new" end rake routes | grep sing_in: new_administrator_session GET /administrators/sign_in devise/sessions#new administrator_session POST /administrators/sign_in devise/sessions#create admin_sign_in GET /admin/sign_in devise/sessions#new I'm running:...

How to modify Devise's message on a specific step of its workflow?

ruby-on-rails,ruby-on-rails-4,devise,devise-confirmable
After Sign Up a new user I get redirected to a Sign In page with the following flash[:alert] message: "You need to sign in or sign up before continuing." My User model uses Devise's :confirmable module so it would be nice if after Sign Up a user would see a...

Devise login through JSON Rails 4 API

json,authentication,ruby-on-rails-4,devise
How exactly can I allow a user to login remotely by sending an encrypted password/email to the devise controllers so I can issue them an API key that I already have setup? Sorry, this whole realm of technology is very new too me, so apologies for the n00b question.

Devise confirmation token invalid

ruby-on-rails,devise
My problem is unrelated to the transition to Devise 3.1+, I already use the @token variable in my email view. The problem is, the confirmation token that is sent via email is not the good one. If I try to do this on the console u = User.last.send_confirmation_instructions the_token_from_the_email =...

How to control Devise user_id value assignment

ruby-on-rails,devise
I've got a simple Rails app the allows users to submit requests. I'm using Devise to register and then authenticate the users. In Devise, user_id is an integer and Devise assigns the value of "1" to the first registered user, then "2" to the second and so on. I want...

Devise - Sign In with Ajax

ruby,ajax,ruby-on-rails-4,devise,warden
Is here any possibility to modify devise SessionsController for ajax communication? Edit I found the solution, and posted it into answers, thanks...

ActiveAdmin: routes for overridden controllers

ruby-on-rails,ruby-on-rails-4,devise,activeadmin
I want to override login for activeadmin. I created SessionsController and override create action like class Admin::SessionsController < ActiveAdmin::Devise::SessionsController def create session[:zzz] = 1 logger.debug("@@@ #{session[:zzz]}") super end end How should I apply the changes for activeadmin devise controller? for devise I would make it like devise_for :users, controllers: {sessions:...

Associate user_id to the comment model?

ruby-on-rails,activerecord,devise
I use devise for authentication, I want to associate user_id to the comment model. It works when I send user_id as a parameter, But I want to set the current logined user's user_id automatically to the each comment. How can I do that? #model/post.rb class Post < ActiveRecord::Base has_many :comments...

How to call update action for another form?Devise

ruby-on-rails,devise
I trying to update devise user attributes from another controller. here is form = form_for @client, url: { action: 'update', controller: '/registrations'} , :html => { method: :patch } do |f| = f.text_field :name = f.text_field :email = f.text_field :phone = f.submit but shell show me an error No route...

Invitation email doesn't have a From: value

ruby-on-rails,devise,devise-invitable
When I invite an user, the email with the inviation link gets sent successfully. However, the email has no From: value, so the mail server returns an error because it (rightfully) refuses to send an email without a From value. So I need to set that value somewhere, but I...

Assigning a User Id to a Nested Model

ruby-on-rails,ruby,ruby-on-rails-4,devise,user
Using Rails 4 with Devise I have a Post model and a Comment model. Comments are nested into Posts. I have assigned posts to a user, but having trouble assigning comments to a user since it is nested. routes.rb resources :posts do resources :comments end user.rb has_many :posts has_many :comments...

Nested Comment body not being saved Ruby on Rails

ruby-on-rails,devise,nested-forms,nested-attributes
I'm banging my head on my desk trying to figure out why the comment is posting comment.body, but when I go into IRB body=nil and it won't display on App show page. The structure: Apps have many comments on their show page, along with a comment form. Apps View: <h3>Comments</h3>...

“Next” button creates a Viewed_Lesson | Ruby on Rails 4 | Learning App

ruby-on-rails,ruby,ruby-on-rails-4,devise
I am trying to make a "next" button that should generate a Viewed_lesson (user_id, lesson_id, boolean: true) and then redirect to the next lesson. The purpose is to make a tracking progress to show the progress of the user over a course. My models: class Course has_many :lessons end class...

Devise conflicting with other routes using delete

ruby-on-rails,ruby-on-rails-4,devise,rails-routing
I have these 2 routes that are conflicting in my application destroy_users DELETE /users/:id(.:format) users#destroy destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy the corresponding part of my routes file is as follows match '/users/:id', to: 'users#destroy', :via => :delete, :as =>:destroy_users devise_for :users resources :users When I try to destroy a session using...

Rails 4.2: Role Based Auth and Separate Attributes

ruby-on-rails,authentication,devise,authorization,table-relationships
I am creating an app with 3 types of Users which could end up with a 4th... Admin Provider Member (patient) The tricky part is each share some common attributes such as 'first_name' and 'last_name', but will have more attributes that differ. If they all share the same 'User' table,...

Devise prevent auto sign-in after registration

ruby-on-rails,ajax,session,devise,registration
Here's my scenario : Users can register on my website by entering their university login. My app checks this login against the university LDAP, and if it exists, it will duplicate the university LDAP entry on my own LDAP + create a database entry for the user on the rails...

Devise Redirect After Cancellation

ruby-on-rails,ruby,redirect,devise
I want to redirect customers to a survey after they cancel their subscription, but having a difficult time getting the session destroyed along with the redirecting to the survey. organizations_controller.rb: def cancel if @organization.subscription.cancel redirect_to "http://example.com/contact/cancel?organization=#{@organization.resource_id}" else flash[:error] = "An error has occurred." redirect_to settings_profile_path end end How can I...

Rails Devise Routes: If user signed in, point to index. Else, point to new user session

ruby-on-rails,ruby,if-statement,devise,routes
Pretty simple question, but I can't seem to find the answer with a good ole fashioned Google. The error: undefined method `user_signed_in?' for #<ActionDispatch::Routing::Mapper:0x007fc6369320e8> (NoMethodError) Server won't even start. My code: Rails.application.routes.draw do devise_for :users, :path_prefix => 'u' resources :users devise_scope :user do get "login", to: "devise/sessions#new", as: :login get...

Rails + Devise: Update user with or without pasword

ruby-on-rails,ruby,devise
There's a ton of related questions: - Devise: Update Account without password confirmation - rails: devise update user without password - Devise 3 (rails 4) can't update user without password - etc... But when I tried to work with their answers I never ended up getting what I wanted so...

Rails how to make this view work? Devise, Enrolment system with courses

ruby-on-rails,model-view-controller,devise
How can I modify the view to make it work? I would like to have a "enroll now button" that will create a viewed_lessons record for the current_user? class Course has_many :lessons end class Lesson #fields: course_id belongs_to :course end class User has_many :viewed_lessons has_many :viewed_courses end class ViewedLesson #fields:...

Customize blank errors in Devise

ruby-on-rails,error-handling,devise,customization
Now I get an error like this: Email can't be blank I can change just this part can't be blank errors: messages: blank: cannot be empty But it after this shows as: Email cannot be empty Can I change field name too? make it like E-mail_something_else cannot be empty? How...

Redirect User back to Page on Login

ruby-on-rails,ruby,devise
I'm using Devise to handle user authentication. I've put a sign in form in another controller view. When a user logs in through this form, I want to redirect them back to that page. I've tried accomplishing this with the following: Application Controller after_filter :store_location def store_location return unless request.get?...

Rails s and bundle install error with pg gem?

ruby-on-rails,ruby,ruby-on-rails-3,devise,gem
I am trying to install Ruby on Rails on my MacBook Pro running Yosemite 10.10 for my school program. I have installed everything successfully but now when I run rails s I get this error. I have tried to continue with bundle install to solve the issue but as you...

Nested form yields parameters with extra level between parent and child

ruby-on-rails,ruby-on-rails-4,devise
I'm building a user and then a plan for that user in one form. I'd expect the parameters to look something like this: "user"=> { "email" => "", "plans_attributes", => { "invite_code" => "", "zipcode => "" } } But instead it looks like this: "user"=> { "email"=>"", "plans_attributes"=> {...

Devise email_field border color changes when email valid

ruby-on-rails,ruby,ruby-on-rails-4,devise,email-validation
Using Devise with Rails 4 I would like my email_field to have a red border until the user inputs an email in a valid format, then it would change to green. I am having trouble finding documentation on doing this so if you can recommend the best way to go...

Rails4 API @current_user getting assigned 1 if not given any value

ruby-on-rails,devise
I am Rails 4 with devise. I have a base controller class Api::BaseController < ApplicationController respond_to :json before_action :current_user def current_user @current_user ||= User.find_by(authentication_token: request.headers['Authorization']) end end `Whenever I send A request with authorization header, @current_user gets the correct user id, but when I don't send Authorization token, @current_user is...

Error when someone tries to repeat an action in rails app — how to handle?

javascript,ruby-on-rails,postgresql,ruby-on-rails-4,devise
I have rails 4 and am running postgresql for an event registration app. Users are registered through devise. If a user has already clicked "join" to register for an event and tries to do it again, they get a generic 404 error. I want to do something like <%= if...

Rendering Error with Devise and Mobylette

ruby-on-rails,mobile,devise,config,renderer
I am using Mobylette with Devise on my Rails 4 app. When I try to sign up, sign in, or reset my password on my mobile device I get this error: ActionController::MissingRenderer (No renderer defined for format: mobile) Has anyone else had this issue? I've tried setting up a fallback...

How to setup angular-rails 4.2 - devise registration/authentication?

ruby-on-rails,angularjs,devise,registration
Can you give an advice or recommend some resources related to this topic? I understand how to it in a theory. But I also heard about jwt etc. What are the best practices to implement device/angular/rails role based auth/registration? All advices will be appreciated....

Private profile for users | rails 4 | devise

ruby-on-rails,devise
I'm trying to implement a private profile page for each user. It's an learning app so people have access to the courses they paid for on their profile page. So other users can't access profile pages by entering URLs... The http response should be 404. So far the idea was...

How to use the same username for different users in different organizations?

ruby-on-rails,authentication,ruby-on-rails-4,login,devise
I use the same user table for all organizations. I have org_id in my users table to allocate the users from different organizations. Now I want to set a unique username for only that organization. For example, org_id = 1 have admin username, org_id = 2 also have admin username....

Couldn't find User with 'id'=show

ruby-on-rails,ruby,devise
a Rails/Devise Question for you today. I'm working on user profiles for a site and I am hitting this error ActiveRecord::RecordNotFound at /users/show Couldn't find User with 'id'=show Not sure exactly what's happening as I haven't really run into anything like this before. Here are some necessary files to take...

How to define current_user in Devise?

ruby-on-rails,devise
I want to print current user email in my RoR app. For this I did use the next code: User.current_user and it prints the next error: undefined methodcurrent_user' for #` but when I used just current_user it doesn't print anything. I did search in Google and Stack, tried to use...

How to create a link that automatically logs the user in on devise / rails?

ruby-on-rails,email,ruby-on-rails-4,devise
I'm trying to make signed up users to take some action on my website, so I want to send then, by e-mail, a link directly to this action. The problem is I want then to be automatically logged in when clicking on that link. I can do something obvious as...

authentication ruby valid_password error

ruby-on-rails,login,devise,passwords
I'm new to ROR. I tried for simple login with email and password. I can't authenticate the password. It's repeated question, and my error is not yet cleared with old questions. My code is user = User.find_by_email(params[:email]) user.valid_password?(params[:password]) if @user = User.find_by_email(params[:user][:email]).valid_password?(params[:user][:password]) #render :json=> user.as_json(:status=>'success', :Message=>'Sucessfully Registered', :username=>user.username ), :status=>201...

Ruby on Rails: dependent object destroyed when transfered from guest user to registered user

ruby-on-rails,ruby,ruby-on-rails-4,devise
Here is my problem: I'm using Devise's guest_user, that contains a logging_in method to transfer guest_user parameters to the registered user when he logs in. So in my case, the user has_many periods, dependent: :destroy, so here is the logging_in method: def logging_in guest_periods = guest_user.periods.all guest_periods.each do |p| p.user_id...

Devise nested attributes form field not showing

ruby-on-rails,ruby,forms,ruby-on-rails-3,devise
I am having trouble viewing the nested attributes field in my form. I am in the jobs/new view and I want have a User form that creates a job as well as a user. I have everything in this answer Rails 4.0 with Devise. Nested attributes Unpermited parameters I have...

How to get the referer url of a previous page in Rails 4

ruby-on-rails,ruby-on-rails-4,devise
I will try to put it in a simple way. I have a Sign Up button (which redirects to /users/sign_up page) on /visitors/owner-faq page. I want the URL of this page(/visitors/owner-faq) after signing up so that i can use it to set something like if sign_up_from_url == '/visitors/owner-faq' @user.role =...

Devise encryption for mobile application

ruby-on-rails,api,encryption,devise
I'm building a RESTfull API for my mobile applications. I have a problem concerning the authentication. I do not want to send the password as readable so I'd like to directly encrypt it before sending it on the network. The problem is that I do not find how to encrypt...

ruby name can't be blank error

ruby-on-rails,forms,devise
it may be a repeated question,but the previous answers doesn't help me i got "name can't be blank", "mobile no cann't be blank" error while sign up the page, even though i filled up the name and mobile no my routes.rb is Rails.application.routes.draw do devise_for :users namespace :api do resources...

How to log in/out users with Devise in Rails4 testing

ruby-on-rails,ruby,ruby-on-rails-4,testing,devise
I'm trying to ensure proper user access is maintained with Devise in Rails 4, and I'm having a hard time logging a user in in the test suite. The simplest case: require 'test_helper' include Devise::TestHelpers class SiteLayoutTest < ActionDispatch::IntegrationTest def setup @user = users(:test1) end test "logged in should get...

Validation failed: User can't be blank

ruby-on-rails,model,devise
All, I am getting the error: Validation failed: User can't be blank. I am getting this error when I save down a comment. Can anyone point me in the right direction possibly? The comments controller class CommentsController < ApplicationController def create @topic = Topic.find(params[:topic_id]) @post = @topic.posts.find(params[:post_id]) @comment = @post.comments.new(params.require(:comment).permit(:body))...