devise

@mymodel.user = current_user is not working for me

痞子三分冷 提交于 2019-12-25 03:49:29
问题 I followed these questions(one and two) on how to adjust my methods with the current user only so they have the specific user_id to edit,update, create and destroy their products. Here is my code: My Migration: class CreateProducts < ActiveRecord::Migration def self.up create_table :products do |t| t.string :name t.date :date t.decimal :price, :default => 0, :precision => 10, :scale => 2 t.integer :user_id t.float :latitude t.float :longitude the Controller: class ProductsController <

Additional user attributes results in UnknownAttributeError and NoMethodError

北城余情 提交于 2019-12-25 03:25:10
问题 Apologies in advance for ultra-long post, just trying to include all the info... I have an app using Devise in which I use a rakefile to seed the database with users among other things. This worked recently, but I can't for the life of me tell what happened over the last few set of changes and it probably just needs a fresh pair of eyes. Here's the bang-head-against-wall twist: running the rakefile on localhost works correctly running the rakefile after pushing to Heroku gives the errors I'll

Devise sign out not signing out

拟墨画扇 提交于 2019-12-25 03:01:47
问题 I'm having trouble signing out with devise. I am creating my signout link like this: <%= link_to "Sign out", destroy_user_session_path %> This was causing problems because the route could not be found so I added this to my routes.rb: get 'sign_out', :to => 'users/sessions#destroy', :as => :destroy_user_session Which does't cause any errors but also doesn't sign out, user_signed_in? still returns true. Any ideas? 回答1: try delete "logout" => "devise/sessions#destroy", :as => "logout" and <%=

Devise sign out not signing out

◇◆丶佛笑我妖孽 提交于 2019-12-25 03:01:31
问题 I'm having trouble signing out with devise. I am creating my signout link like this: <%= link_to "Sign out", destroy_user_session_path %> This was causing problems because the route could not be found so I added this to my routes.rb: get 'sign_out', :to => 'users/sessions#destroy', :as => :destroy_user_session Which does't cause any errors but also doesn't sign out, user_signed_in? still returns true. Any ideas? 回答1: try delete "logout" => "devise/sessions#destroy", :as => "logout" and <%=

Devise: Don't redirect on password reset if already logged in

半城伤御伤魂 提交于 2019-12-25 02:52:26
问题 If a user is already logged in and clicks on a password reset link from their email, they automatically get redirected to the logged in area. I want the user to be able to reset their password, logged in or not. How do I prevent the redirect? 回答1: What you are trying to do is, use Devise recoverable module to change a logged in user password. This is not what recoverable module was built for. As per carlosantoniodasilva , a Collaborator of Devise This feature is for recovering passwords, not

How do you get rspec to output what it encountered rather than it “didn't find what it expected”?

余生长醉 提交于 2019-12-25 02:50:32
问题 I have been struggling to using ruby/rspec/capybara/devise to test my code. A simple test I am trying to write is for signing in. I have a valid user sign in and expect to see an h1 tag as defined in the following code: describe "Authentication" do subject { page } describe "with valid information" do let(:user) { FactoryGirl.create(:user) } before { sign_in_with user.email } it { should have_css('h1', text: "Welcome to the Test") } end end Problem is that I get this in return: 1)

Modify Devise alerts ( Rails 3)

走远了吗. 提交于 2019-12-25 02:33:03
问题 I am using devise in my rails app which comes with its own alert/flash helpers. I have modified it so that it looks like this <% flash.each do |key, value| %> <%= content_tag(:div, value, :class => "flash #{key}") %> <% end %> What i want to do is to be able to close this alert with a X in the top corner, rather than refresh the page to make it disappear. I have created an alert box with css/jquery and surrounded the relevant divs around the above code, however as its in the layouts

undefined method `username' for nil:NilClass when signing up and signing in

倖福魔咒の 提交于 2019-12-25 02:28:09
问题 Whenever I try to log in and sign up, I am hit with this error: undefined method `username' for nil:NilClass on these two lines: <strong><%= @user.username %></strong> <br> <strong><%= @user.name %></strong> Here is the full error from the server's output: User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."username" = 'sign_in' LIMIT 1 Rendered users/show.html.erb within layouts/application (2.1ms) Completed 500 Internal Server Error in 7ms ActionView::Template::Error (undefined

Rails 3 devise user registration edit path not working

我只是一个虾纸丫 提交于 2019-12-25 02:16:27
问题 I have a pretty straight forward app with a couple tweaks to Devise. First I created a Registrations controller that class RegistrationsController < Devise::RegistrationsController inherits from Devise. I created this controller so that I could edit users without re-supplying passwords. https://gist.github.com/1514687 I also did this in my routes: devise_for :users, :controllers => { :registrations => "registrations" }` The signup works fine but when I call the following: <p class="edit"><%=

Facebook App using Devise is redirecting away from FB Canvas

巧了我就是萌 提交于 2019-12-25 02:15:37
问题 When the user installs my facebook app for the first time, a facebook logo is displayed, permissions are requested, and then the user is popped out of the iframe. I applied the directions recently (Oct 14th) added to the OmniAuth Overview wiki page on the devise site regarding lost sessions. And this has fixed all my redirect issues except when the permissions dialog shows up. Anyone else seeing this? Any idea how to fix? Help! 回答1: Figured it out on my own. The OmniAuth Overview wiki page