Displaying 13 results from an estimated 13 matches for "require_user".
2011 Jun 01
7
desperate, errors with file upload
hello,
i implementing a file upload using paperclip plugin. i getting the
following error [1] when uploading a file. I''m using the gems rails
v2.3.8 and paperclip v2.1.6. the parameter hash looks like [2], the
model like [3].
Interesting is that i get two different errors, on the localhost with
webrick it says:
Status: 500 Internal Server Error
no marshal_dump is defined for class
2009 Oct 28
1
Authlogic Page View Authentication Help
...@current_user_session if defined?
(@current_user_session)
@current_user_session = UserSession.find
end
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session &&
current_user_session.user
end
def require_user
unless current_user
store_location
flash[:notice] = "You must be logged in to access this page"
redirect_to new_user_session_url
return false
end
end
Now I want only users to be logged in to upload photos. So if the hit
the upload link it takes them to a page, and...
2008 Dec 16
20
step definitons to check login
...orking with the authlogic gem and trying to create a simple login
test from cucumber features. The feature statement is:
Given the user is not logged in
The step definition for this is confounding me. In the
application_controller the authlogic tutorial recommends the following:
private
def require_user
unless current_user
store_location
flash[:notice] = "You must sign in to access this page"
redirect_to new_user_session_url
return false
end
end
def require_no_user
if current_user
store_location
flash[:notice] = &...
2010 Mar 15
3
Before_filters on re-rendered methods - what is the correct RAILS way?
...create
action.
Is there a right way to do this or is this just a really un-rails way
of doing this - in which case how should it be done normally?
Thanks for your help!
Sample Code (Rails v2.3.4):
---------------------------
class EntryController < ApplicationController
before_filter :require_user, :only => [:create]
# ==new
# new_entry_url (GET /entries/new)
def new
# Display user a form page where they can fill
# in details of a new entry, which will then
# submit a post request to "confirm"
end
# ==confirm
# confirm_new_entry_ur...
2006 Apr 18
4
Mixin variables
...my module, I''ve set up the set_login_pages method like this:
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def set_login_pages(*login_page_list)
@login_pages = login_page_list
end
end
But then when I try to access @login pages in the require_user method,
it''s blank.
What am I doing wrong?
--
Posted via http://www.ruby-forum.com/.
2009 Oct 18
4
NoMethodError in User sessionsController#new
I''m setting up authentication with Authlogic and I get this error.
I''ve done some searching but with no success. I tried setting the
current_user method in Application_controller to protected and not
private, on the recommendation in Stack Overflow.
Error in browser-----------------
NoMethodError in User sessionsController#new
undefined method `require_no_user'' for
2010 Nov 07
1
Strange authlogic logout behavior
...)
Now if I login and the click on some other links within the application
and then logout, the logout function works as it should.
user_sessions controller
[code]
class UserSessionsController < ApplicationController
before_filter :require_no_user, :only => [:new, :create]
before_filter :require_user, :only => :destroy
def new
@user_session = UserSession.new
end
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = "Login successful!"
redirect_to :controller => "list"
else
rend...
2011 Jun 29
6
RSpec with Rails 3.1rc4: spec test won't recognize <%= %> (should be simple)
In my user_sessions_controller:
class UserSessionsController < ApplicationController
before_filter :require_no_user, :only => [:create, :new]
before_filter :require_user, :only => :destroy
def new
@user_session = UserSession.new
@message = "Hello."
end
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = "Login successful!"
redirect_back_or_default adm...
2008 Jun 28
19
Stopping example execution?
...ing If I am missing something here when creating an example that sets an expecation at the top or beginning of an action but requires you to stub / mock everything that follows.
Example:
I want to test that a certain controller is running a before_filter...thats easy:
- controller.should_receive(:require_user)
- do_get
But now i''ve got to mock / stub everything else that comes behind this filter so that I don''t receive ''unexpected method'' errors, or other blowups because I am requesting the whole action. Is there anyway to stop execution after an expectation has bee...
2009 Jul 25
3
Rails Authorization and Security question
Working through the Users and Authentication of Learning Rails book
(great book, code needs to be proof-read in a few cases, though), I
came across this:
There''s still one leftover that may be worth addressing, depending on
your security needs. The authorization? method has secured the data,
and the view no longer shows the user options they can''t really use,
but if a
2009 Sep 24
13
Rails Authentication Tutorial
Does anyone know a good authentication tutorial they can suggest? I''ve
tried several restful authentication ones and an authlogic one on
RailsCast. But with each one I try, something seems to be missing in
the tutorial and I can''t get it to work. I''m new to Rails so it''s
possible user error on my part.
I''m on Mac OS X 10.5 and I generate all my apps in
2010 Oct 21
4
Authlogic + Rails3 - undefined method `Login' for nil:NilClass
...rd? ? nil : [ self.send(self.class.primary_key) ]
end
end
models/user.rb:
class User < ActiveRecord::Base
acts_as_authentic
end
controllers/users_controller.rb:
class UsersController < ApplicationController
before_filter :require_no_user, :only => [:new, :create]
before_filter :require_user, :only => [:show, :edit, :update]
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
flash[:notice] = "Account registered!"
redirect_back_or_default account_url
else
render :action => :new
end
end...
2009 Dec 25
18
rescue_from ActionController::RoutingError II
...return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session &&
current_user_session.record
end
def require_user
unless current_user
store_location
flash[:notice] = "You must be logged in to access this page"
redirect_to new_user_session_url
return false
end
end
def require_no_user
if current_user
store_location
flash[:notice...