Displaying 20 results from an estimated 300 matches similar to: "Accessing the name of a controller''s module?"
2006 Aug 07
8
Rails Recipes question - authenticating users
Didn''t think I''d be back so quick with another question but here goes:
In this recipe for the signin or login (as I call it) there are these
two lines if the user authenticates correctly:
session[:user] = user.id
redirect_to :action => session[:intended_action],
:controller => session[:intended_controller]
So I''m not seeing anything in the way of an explanation
2006 Aug 07
2
Ugggh..another recipes question
sorry, because it seems that I need more explanation on this Rails
Recipes authorization -
I finally got the code working but after using the login I get this
back from Rails-
Routing Error
No url can be generated for the hash {}
I''m guessing it''s coming from the redirect-
def login
if request.post?
session[:user] = User.authenticate(params[:first_name],
2006 Aug 13
3
Render nothing; go nowhere
I am building an application that requires a C++ program to access the
Rails web application using POST. Now, I just added user authentication
to the mix and it has made things more interesting.
I''m using basic authentication as shown in the AWDWR and Rails Recipes
books. I can now get my C++ program to submit the user credentials to
the login/login page. All I want the login page
2006 Jun 30
8
before_filter: nil vs. true vs. false
Folks,
My understanding of how filters work is that I should return true if
everything is ok and false if not. How does the filter below work
then (from the Rails Recipies book)?
It would return nil if there''s a user in the session. Does nil count
as true?
before_filter :check_authentication
def check_authentication
unless session[:user]
session[:intended_action] =
2006 Jul 02
3
2 before_filters, only want one to render something
I have two before_filters for a few of my controllers. They are running
my own methods authorize and admin_authorize. authorize is called on
just about every action to make sure that a user is logged in.
admin_authorize is called on about 80% of the actions and is used to
make sure that a user is an administrator. If a user tries to access an
admin_authorize protected action without being
2006 Aug 01
0
How to retrieve :web when redirecting to an Instiki page?
Hello, I am currently working on implementing some authentification code
onto Instiki (0.11.0). I am encountering a problem in this situation :
When I try to access say http:/localhost:2500/orz/show/Test , where orz
is an instiki web name, I am redirected to my signin form screen (which
is what I want) but then upon signing in I get the following message:
No url can be generated for the hash
2006 Mar 13
7
Problem with params
I''ve got a User model, which holds the following (excerpt):
def try_to_authenticate
User.authenticate(self.username, self.password)
end
..
private
def self.hash_password(password)
Digest::SHA1.hexdigest(password)
end
def self.authenticate(username, password)
@user = User.find(:all, :conditions => ["username = ? AND
password = ?",
2009 Jun 19
1
Session Reset when clicking back button of the browser
hi friends...
here is my query....
kindly give ur views pls...
after logging into the application,i redirect to company list page.now
when user clicks the browser back button it should show the login
page.that is i want to destroy the session.so in my login controller i
have written code below.
def log_in
if request.get?
reset_session
end
end
in my routes.rb
map.root :controller =>
2006 Jul 30
1
custom routing in simply_restful
Is there information on how I can define custom paths/actions other than
these:
/users/new GET new
/users/id;edit GET edit
so for example I can have my own:
/users/log_in GET log_in
/users/id;process_log_in GET process_log_in
So far I cannot find any documentations on these at all.
--
Posted via http://www.ruby-forum.com/.
2006 Aug 12
7
Redirect back to last page?
I have a few pages where a user may do something (add tags, login, etc)
and I would like to redirect them back to the last page they were at
before calling that action. Is there an easy way to do this?
--
Posted via http://www.ruby-forum.com/.
2006 Aug 07
8
Login form question
I''m using Rails Recipes to create a login form but instead of username
and password, my setup is firstname, lastname, password.
I seemed to be gramatically challenged and not sure how to set up the
parameter list. Can anyone offer up a suggestion.
The book shows the method starting like:
if request.post?
user = User.find(:first, :conditions => [''username = ?'' ,
2006 Jul 07
13
Rails Recipes Book: Authentication
Hi,
The user/login management system in Chapter 31: Authenticating Your
Users and Chapter 32: Authorizing Users with Roles of Chad Fowler''s
Rails Recipes looks reasonable and adequate. However, when I ran the
Chapter 31 code, I get the following error:
Username or password invalid
And I am not even given the chance to sign in; that is, the signin form
does not appear at all.
Has
2006 Apr 21
1
Catch authentication result from a model in a controller
Im still following the authorization recipe from the book, now all works
fine but im getting trouble in how handle the model authorization
result, if the user and pass are correct, it goes to a welcome
screen(admin.rhtml) but if wrong the model prints a message in an ugly
exception like page "usr and pass not correct", i want to redirect the
user to the login
2006 Aug 14
2
ajax - layout problem.
Hi guys
Here is my problem...
Using Ajax to update a div with link_to_remote. Problem is I have a layout
defined in my class, so, the div gets the layout when I call the method, how
di I tell a method to ingore the layout?
Cheers.
Pieter.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2006 May 19
0
No luck with multiple before_filters
I''ve got these two lines set up in my controller
before_filter :check_authentication
before_filter :check_max_hands, :only => [ :play ]
Here''s the corresponding code for each
def check_authentication
unless session[:user] and authorize?(session[:user])
session[:intended_action] = request.request_uri
redirect_to :controller => ''user'',
2008 Jan 19
5
"should_not ==" vs "should !="
describe "should_not == vs. should !="
it do
5.should_not == 6
end # passes
it do
5.should != 6
end # fails
end
# I''m running the rspec 1.1.2 gem with the corresponding Textmate bundle
# The second failure surprises me.
# Is != not supported?
# I''d like to hear what you all think.
-------------- next part --------------
An HTML attachment was
2007 Jan 20
2
Conditional pluralize without the number
Hi.
Assume you have an array of person names. I want to generate results in
my view that look like this:
Abby is your friend
or
Abby, Bob, and Carol are your friends.
So I''d like to say:
<%= friends.to_sentence %>
<%= pluralize(friends.count, "is") %>
your <%= pluralize(friends.count, "friend") %>
But because pluralize puts in the
2008 Jun 03
5
Autotest/RSpec 1.1.4/Rails 2.1 Infinite Loop?
I just got back from RailsConf, and upgraded on of my development apps
to 2.1, and now autotest is going into an infinite loop. It runs tests
continuously instead of waiting for files to be saved before rerunning.
Has anybody else seen this, or know how to get around it?
Thanks,
Andrew
2006 Jan 04
0
Simple print statement (was: recongizing the current controller in views)
All (and kevin),
After flying high for a while on Rails things, I''m down to the nitty gritty of
Ruby stuff. Messing with vars and printing them out on a web page.
I found the controller_path in the API docs;
However when putting this in a controller:
@test1 = controller_class_name
@test2 = controller_name
@test3 = controller_path
And this in a partial:
Test1 <%= @test1
2006 Aug 14
3
validating required fields during an update?
I have a User model with an email attribute. I''m using the following
validations:
validates_confirmation_of :email
validates_format_of :email,
:with => RFC822::EmailAddress,
:message => "must be a valid address in the form user@domain.com"
validates_uniqueness_of :email, :message => "address has already
been taken. If you''ve forgotten your